
package server.maps;


import client.*;
import client.inventory.Equip;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import client.inventory.MaplePet;
import client.skills.KSPsychicSkillEntry;
import client.skills.Skill;
import client.skills.SkillFactory;
import client.status.MonsterStatus;
import client.status.MonsterStatusEffect;
import com.alibaba.druid.pool.DruidPooledConnection;
import configs.ServerConfig;
import constants.*;
import database.DatabaseConnection;
import handling.channel.ChannelServer;
import handling.opcode.EffectOpcode;
import handling.opcode.FieldEffectOpcode;
import handling.world.PartyOperation;
import handling.world.WorldBroadcastService;
import handling.world.party.ExpeditionType;
import scripting.event.EventInstanceManager;
import scripting.event.EventManager;
import scripting.map.MapScriptMethods;
import server.*;
import server.Timer;
import server.life.*;
import server.quest.MapleQuest;
import server.squad.MapleSquad;
import server.squad.MapleSquadType;
import tools.*;
import tools.packet.*;

import java.awt.*;
import java.sql.PreparedStatement;
import java.util.*;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.stream.Collectors;






























































 public final class MapleMap {
       private final Map<MapleMapObjectType, LinkedHashMap<Integer, MapleMapObject>> mapobjects;
    /*   65 */   private final List<MapleCharacter> characters = new ArrayList<>();
    private final Map<MapleMapObjectType, ReentrantReadWriteLock> mapobjectlocks;
    /*   66 */   private final ReentrantReadWriteLock charactersLock = new ReentrantReadWriteLock();
    /*   67 */   private final Lock runningOidLock = new ReentrantLock();
    /*   68 */   private final List<MapleHideNpc> hideNpc = new ArrayList<>();
    /*   69 */   private final List<Spawns> monsterSpawn = new ArrayList<>();
    /*   70 */   private final AtomicInteger runningOid = new AtomicInteger(500000);
    /*   71 */   private final AtomicInteger spawnedMonstersOnMap = new AtomicInteger(0);
    /*   72 */   private final AtomicInteger spawnedForcesOnMap = new AtomicInteger(0);
    /*   73 */   private final AtomicInteger spawnedMistOnMap = new AtomicInteger(0);
    /*   74 */   private final Map<Integer, MaplePortal> portals = new HashMap<>();
    /*   75 */   private final Map<Integer, Map<Integer, List<Pair<Integer, Integer>>>> kspsychicObjects = new LinkedHashMap<>();
    /*   76 */   private final ReentrantReadWriteLock kspsychicLock = new ReentrantReadWriteLock();
    /*   77 */   private final Map<Integer, Integer> ksultimates = new LinkedHashMap<>();
       private final float monsterRate;
       private final int channel;
       private final int mapid;
    /*   81 */   private final List<Integer> dced = new ArrayList<>();
    /*   82 */   private MapleFootholdTree footholds = null;
       private float recoveryRate;
       private MapleMapEffect mapEffect;
    /*   85 */   private short decHP = 0;
    private short createMobInterval = 9000;
    private short top = 0;
    private short bottom = 0;
    private short left = 0;
    private short right = 0;
    /*   86 */   private int consumeItemCoolTime = 0;
    /*   87 */   private int protectItem = 0;
    /*   88 */   private int decHPInterval = 10000;
       private int returnMapId;
       private int timeLimit;
       private int fieldLimit;
    /*   92 */   private int maxRegularSpawn = 0;
       private int fixedMob;
    /*   94 */   private int forcedReturnMap = 999999999;
    /*   95 */   private int instanceid = -1;
    /*   96 */   private int lvForceMove = 0;
    /*   97 */   private int lvLimit = 0;
    /*   98 */   private int permanentWeather = 0;
    /*   99 */   private int partyBonusRate = 0;
    private boolean town;
    private boolean clock;
    private boolean personalShop;
    private boolean miniMapOnOff;
    private boolean everlast = false;
    private boolean dropsDisabled = false;
    private boolean gDropsDisabled = false;
    private boolean soaring = false;
    private boolean squadTimer = false;
    private boolean isSpawns = true;
    private boolean checkStates = true;
    private String mapName;
    private String streetName;
       private String onUserEnter;
       private String onFirstUserEnter;
    /*  102 */   private String speedRunLeader = "";
    /*  103 */   private List<Point> spawnPoints = new ArrayList<>();
       private ScheduledFuture<?> squadSchedule;
    /*  105 */   private long speedRunStart = 0L;
    private long lastSpawnTime = 0L;
    private long lastHurtTime = 0L;
    /*  106 */   private final AtomicInteger spawnedSwordOnMap = new AtomicInteger(0);
    private boolean 进阶半半地图;
    private MapleNodes nodes;
    private MapleSquadType squad;
    private Map<Integer, MapleSwordNode> swordNodes;



    public boolean is进阶半半地图() {
        /*  109 */
        return this.进阶半半地图;

    }



    public void set进阶半半地图(boolean 进阶半半地图) {
        /*  113 */
        this.进阶半半地图 = 进阶半半地图;

    }






    /*  120 */   private long spawnRuneTime = 0L;

       private int fieldType;
       private boolean entrustedFishing;



    public MapleMap(int mapid, int channel, int returnMapId, float monsterRate) {
        /*  126 */
        this.mapid = mapid;
        /*  127 */
        this.channel = channel;
        /*  128 */
        this.returnMapId = returnMapId;
        /*  129 */
        if (this.returnMapId == 999999999) {
            /*  130 */
            this.returnMapId = mapid;

        }

        /*  133 */
        this.进阶半半地图 = (mapid == 105200510);

        /*  135 */
        if (GameConstants.getPartyPlay(mapid) > 0) {
            /*  136 */
            this.monsterRate = (monsterRate - 1.0F) * 2.5F + 1.0F;

        } else {
            /*  138 */
            this.monsterRate = monsterRate;

        }
        /*  140 */
        EnumMap<MapleMapObjectType, LinkedHashMap<Integer, MapleMapObject>> objsMap = new EnumMap<>(MapleMapObjectType.class);
        /*  141 */
        EnumMap<MapleMapObjectType, ReentrantReadWriteLock> objlockmap = new EnumMap<>(MapleMapObjectType.class);
        /*  142 */
        for (MapleMapObjectType type : MapleMapObjectType.values()) {
            /*  143 */
            objsMap.put(type, new LinkedHashMap<>());
            /*  144 */
            objlockmap.put(type, new ReentrantReadWriteLock());

        }
        /*  146 */
        this.mapobjects = Collections.unmodifiableMap(objsMap);
        /*  147 */
        this.mapobjectlocks = Collections.unmodifiableMap(objlockmap);

    }



    public int getFieldType() {
        /*  151 */
        return this.fieldType;

    }



    public void setFieldType(int fieldType) {
        /*  155 */
        this.fieldType = fieldType;

    }



    public boolean getSpawns() {
        /*  159 */
        return this.isSpawns;

    }



    public void setSpawns(boolean fm) {
        /*  163 */
        this.isSpawns = fm;

    }



    public void setFixedMob(int fm) {
        /*  167 */
        this.fixedMob = fm;

    }



    public int getForceMove() {
        /*  171 */
        return this.lvForceMove;

    }



    public void setForceMove(int fm) {
        /*  175 */
        this.lvForceMove = fm;

    }



    public int getLevelLimit() {
        /*  179 */
        return this.lvLimit;

    }



    public void setLevelLimit(int fm) {
        /*  183 */
        this.lvLimit = fm;

    }



    public void setSoaring(boolean b) {
        /*  187 */
        this.soaring = b;

    }



    public boolean canSoar() {
        /*  191 */
        return this.soaring;

    }



    public void toggleDrops() {
        /*  195 */
        this.dropsDisabled = !this.dropsDisabled;

    }



    public void setDrops(boolean b) {
        /*  199 */
        this.dropsDisabled = b;

    }



    public void toggleGDrops() {
        /*  203 */
        this.gDropsDisabled = !this.gDropsDisabled;

    }



    public int getId() {
        /*  207 */
        return this.mapid;

    }



    public MapleMap getReturnMap() {
        /*  211 */
        return ChannelServer.getInstance(this.channel).getMapFactory().getMap(this.returnMapId);

    }



    public int getReturnMapId() {
        /*  215 */
        return this.returnMapId;

    }



    public void setReturnMapId(int rmi) {
        /*  219 */
        this.returnMapId = rmi;

    }



    public int getForcedReturnId() {
        /*  223 */
        return this.forcedReturnMap;

    }



    public MapleMap getForcedReturnMap() {
        /*  227 */
        return ChannelServer.getInstance(this.channel).getMapFactory().getMap(this.forcedReturnMap);

    }



    public void setForcedReturnMap(int map) {
        /*  231 */
        this.forcedReturnMap = map;

    }



    public float getRecoveryRate() {
        /*  235 */
        return this.recoveryRate;

    }



    public void setRecoveryRate(float recoveryRate) {
        /*  239 */
        this.recoveryRate = recoveryRate;

    }



    public int getFieldLimit() {
        /*  243 */
        return this.fieldLimit;

    }



    public void setFieldLimit(int fieldLimit) {
        /*  247 */
        this.fieldLimit = fieldLimit;

    }



    public void setCreateMobInterval(short createMobInterval) {
        /*  251 */
        this.createMobInterval = createMobInterval;

    }



    public void setTimeLimit(int timeLimit) {
        /*  255 */
        this.timeLimit = timeLimit;

    }



    public String getMapName() {
        /*  259 */
        return this.mapName;

    }



    public void setMapName(String mapName) {
        /*  263 */
        this.mapName = mapName;

    }



    public String getStreetName() {
        /*  267 */
        return this.streetName;

    }



    public void setStreetName(String streetName) {
        /*  271 */
        this.streetName = streetName;

    }



    public String getFirstUserEnter() {
        /*  275 */
        return this.onFirstUserEnter;

    }



    public void setFirstUserEnter(String onFirstUserEnter) {
        /*  279 */
        this.onFirstUserEnter = onFirstUserEnter;

    }



    public String getUserEnter() {
        /*  283 */
        return this.onUserEnter;

    }



    public void setUserEnter(String onUserEnter) {
        /*  287 */
        this.onUserEnter = onUserEnter;

    }



    public boolean hasClock() {
        /*  291 */
        return this.clock;

    }



    public void setClock(boolean hasClock) {
        /*  295 */
        this.clock = hasClock;

    }



    public boolean isTown() {
        /*  299 */
        return this.town;

    }



    public void setTown(boolean town) {
        /*  303 */
        this.town = town;

    }



    public boolean allowPersonalShop() {
        /*  307 */
        return this.personalShop;

    }



    public void setPersonalShop(boolean personalShop) {
        /*  311 */
        this.personalShop = personalShop;

    }



    public boolean getEverlast() {
        /*  315 */
        return this.everlast;

    }



    public void setEverlast(boolean everlast) {
        /*  319 */
        this.everlast = everlast;

    }



    public int getHPDec() {
        /*  323 */
        return this.decHP;

    }



    public void setHPDec(int delta) {
        /*  327 */
        if (delta > 0 || this.mapid == 749040100) {
            /*  328 */
            this.lastHurtTime = System.currentTimeMillis();

        }
        /*  330 */
        this.decHP = (short) delta;

    }



    public int getHPDecInterval() {
        /*  334 */
        return this.decHPInterval;

    }



    public void setHPDecInterval(int delta) {
        /*  338 */
        this.decHPInterval = delta;

    }



    public int getHPDecProtect() {
        /*  342 */
        return this.protectItem;

    }



    public void setHPDecProtect(int delta) {
        /*  346 */
        this.protectItem = delta;

    }



    public void addHideNpc(MapleHideNpc qm) {
        /*  350 */
        this.hideNpc.add(qm);

    }



    public boolean isMiniMapOnOff() {
        /*  354 */
        return this.miniMapOnOff;

    }



    public void setMiniMapOnOff(boolean on) {
        /*  358 */
        this.miniMapOnOff = on;

    }



    public List<Point> getSpawnPoints() {
        /*  362 */
        return this.spawnPoints;

    }



    public void setSpawnPoints(List<Point> Points) {
        /*  366 */
        this.spawnPoints = Points;

    }



    public List<MapleMapObject> getCharactersAsMapObjects() {
        /*  370 */
        return getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Collections.singletonList(MapleMapObjectType.PLAYER));

    }



    public int getCurrentPartyId() {
        /*  374 */
        this.charactersLock.readLock().lock();

        try {
            /*  376 */
            Iterator<MapleCharacter> ltr = this.characters.iterator();

            /*  378 */
            while (ltr.hasNext()) {
                /*  379 */
                MapleCharacter chr = ltr.next();
                /*  380 */
                if (chr.getParty() != null) {
                    /*  381 */
                    return chr.getParty().getPartyId();

                }

            }

        } finally {
            /*  385 */
            this.charactersLock.readLock().unlock();

        }
        /*  387 */
        return -1;

    }








    public void addMapObject(MapleMapObject mapobject) {
        /*  396 */
        this.runningOidLock.lock();

        try {
            /*  398 */
            if (mapobject.getObjectId() != 0) {
                /*  399 */
                mapobject.setObjectId(mapobject.getObjectId());

            } else {
                /*  401 */
                mapobject.setObjectId(this.runningOid.getAndIncrement());

            }

        } finally {
            /*  404 */
            this.runningOidLock.unlock();

        }
        /*  406 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(mapobject.getType())).writeLock().lock();

        try {
            /*  408 */
            ((LinkedHashMap<Integer, MapleMapObject>) this.mapobjects.get(mapobject.getType())).put(Integer.valueOf(mapobject.getObjectId()), mapobject);

        } finally {
            /*  410 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(mapobject.getType())).writeLock().unlock();

        }

    }



    public void spawnMapObject(MapleMapObject mapobject, DelayedPacketCreation packetbakery) {
        /*  415 */
        addMapObject(mapobject);
        /*  416 */
        spawnAndAddRangedMapObject(mapobject, packetbakery);

    }



    public void disappearMapObject(MapleMapObject mapobject) {
        /*  420 */
        removeMapObject(mapobject);
        /*  421 */
        removeRangedMapObject(mapobject);

    }






    private void spawnAndAddRangedMapObject(MapleMapObject mapobject, DelayedPacketCreation packetbakery) {
        /*  428 */
        addMapObject(mapobject);

        /*  430 */
        this.charactersLock.readLock().lock();

        try {
            /*  432 */
            Iterator<MapleCharacter> itr = this.characters.iterator();

            /*  434 */
            while (itr.hasNext()) {
                /*  435 */
                MapleCharacter chr = itr.next();
                /*  436 */
                if (mapobject.getType() == MapleMapObjectType.MIST || 0 <= GameConstants.maxViewRangeSq().doubleValue()) {
                    /*  437 */
                    packetbakery.sendPackets(chr.getClient());
                    /*  438 */
                    chr.addVisibleMapObject(mapobject);

                }

            }

        } finally {
            /*  442 */
            this.charactersLock.readLock().unlock();

        }

    }








    public void removeMapObject(MapleMapObject obj) {
        /*  452 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(obj.getType())).writeLock().lock();

        try {
            /*  454 */
            ((LinkedHashMap) this.mapobjects.get(obj.getType())).remove(Integer.valueOf(obj.getObjectId()));

        } finally {
            /*  456 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(obj.getType())).writeLock().unlock();

        }

    }



    public void removeRangedMapObject(MapleMapObject obj) {
        /*  461 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.PLAYER)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.PLAYER)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject o2 = (MapleMapObject) var2.next();
                MapleCharacter player = (MapleCharacter) o2;
                if (player.isMapObjectVisible(obj)) {
                    player.removeVisibleMapObject(obj);
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.PLAYER)).readLock().unlock();
        }


    }



    public Point calcPointBelow(Point initial) {
        /*  475 */
        MapleFoothold fh = this.footholds.findBelow(initial, false);
        /*  476 */
        if (fh == null) {
            /*  477 */
            return null;

        }
        /*  479 */
        int dropY = fh.getY1();
        /*  480 */
        if (!fh.isWall() && fh.getY1() != fh.getY2()) {
            /*  481 */
            double s1 = Math.abs(fh.getY2() - fh.getY1());
            /*  482 */
            double s2 = Math.abs(fh.getX2() - fh.getX1());
            /*  483 */
            double s5 = Math.cos(Math.atan(s2 / s1)) * Math.abs(initial.x - fh.getX1()) / Math.cos(Math.atan(s1 / s2));
            /*  484 */
            if (fh.getY2() < fh.getY1()) {
                /*  485 */
                dropY = fh.getY1() - (int) s5;

            } else {
                /*  487 */
                dropY = fh.getY1() + (int) s5;

            }

        }
        /*  490 */
        return new Point(initial.x, dropY);

    }



    public Point calcDropPos(Point initial, Point fallback) {
        /*  494 */
        Point ret = calcPointBelow(new Point(initial.x, initial.y - 50));
        /*  495 */
        if (ret == null) {
            /*  496 */
            return fallback;

        }
        /*  498 */
        return ret;

    }



    private void dropFromMonster(MapleCharacter chr, MapleMonster mob, boolean instanced) {
        /*  502 */
        if (mob == null || chr == null || ChannelServer.getInstance(this.channel) == null || this.dropsDisabled || mob.dropsDisabled() || chr.getPyramidSubway() != null || ServerConfig.WORLD_BANDROPITEM) {

            return;

        }


        /*  507 */
        if (ServerConfig.CHANNEL_MONSTER_GIVECASH > 0) {
            /*  508 */
            chr.modifyCSPoints(1, ServerConfig.CHANNEL_MONSTER_GIVECASH);

        }


        /*  512 */
        if (ServerConfig.CHANNEL_MONSTER_GIVEPOINT > 0) {
            /*  513 */
            chr.modifyCSPoints(2, ServerConfig.CHANNEL_MONSTER_GIVEPOINT);

        }


        /*  517 */
        if (!instanced && ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.ITEM)).size() >= ServerConfig.CHANNEL_DROP_CLEARMAX) {
            /*  518 */
            removeDropsDelay();
            /*  519 */
            if (chr.isAdmin()) {
                /*  520 */
                chr.dropMessage(6, "[系统提示] 当前地图的道具数量达到 " + ServerConfig.CHANNEL_DROP_CLEARMAX + " 系统已自动清理掉所有地上的物品信息.");

            }

        }
        /*  523 */
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        /*  524 */
        byte droptype = (byte) (mob.getStats().isExplosiveReward() ? 3 : (mob.getStats().isFfaLoot() ? 2 : ((chr.getParty() != null) ? 1 : 0)));
        /*  525 */
        int mobpos = (mob.getTruePosition()).x;
        /*  526 */
        int mesoServerRate = ChannelServer.getInstance(this.channel).getMesoRate();
        /*  527 */
        int dropServerRate = ChannelServer.getInstance(this.channel).getDropRate();

        /*  529 */
        int globalServerRate = ChannelServer.getInstance(this.channel).getDropgRate();

        /*  531 */
        byte d = 1;
        /*  532 */
        Point pos = new Point(0, (mob.getTruePosition()).y);
        /*  533 */
        double 挑衅加成 = 100.0D;
        /*  534 */
        MonsterStatusEffect mse = mob.getBuff(MonsterStatus.MOB_STAT_Showdown);
        /*  535 */
        if (mse != null) {
            /*  536 */
            挑衅加成 += mse.getX().intValue();

        }

        /*  539 */
        MapleMonsterInformationProvider mi = MapleMonsterInformationProvider.getInstance();
        /*  540 */
        List<MonsterDropEntry> derp = mi.retrieveDrop(mob.getId());

        /*  542 */
        if (derp.isEmpty()) {

            return;

        }
        /*  545 */
        List<MonsterDropEntry> dropEntry = new LinkedList<>(derp);
        /*  546 */
        Collections.shuffle(dropEntry);

        /*  548 */
        boolean mesoDropped = false;
        /*  549 */
        for (MonsterDropEntry de : dropEntry) {
            /*  550 */
            Item idrop = new Item();
            if (de.itemId == mob.getStolen()) {

                continue;

            }
            /*  553 */
            if (Randomizer.nextInt(999999) >= (int) ((de.chance * dropServerRate * chr.getDropMod()) * chr.getStat().getDropBuff() / 100.0D * 挑衅加成 / 100.0D) || (
                    /*  554 */         mesoDropped && droptype != 3 && de.itemId == 0)) {

                continue;

            }
            /*  557 */
            if (de.itemId / 10000 == 238) {

                continue;

            }
            /*  560 */
            if (de.questid != 0 && chr.getQuestStatus(de.questid) <= 0) {

                continue;

            }
            /*  563 */
            if (droptype == 3) {
                /*  564 */
                pos.x = mobpos + ((d % 2 == 0) ? (40 * (d + 1) / 2) : -(40 * d / 2));

            } else {
                /*  566 */
                pos.x = mobpos + ((d % 2 == 0) ? (20 * (d + 1) / 2) : -(20 * d / 2));

            }
            /*  568 */
            if (de.itemId == 0) {
                /*  569 */
                int mesos = Randomizer.nextInt(1 + Math.abs(de.maximum - de.minimum)) + de.minimum;
                /*  570 */
                if (mesos > 0) {
                    /*  571 */
                    spawnMobMesoDrop((int) (mesos * (chr.getStat()).mesoBuff / 100.0D * chr.getDropMod() * mesoServerRate), calcDropPos(pos, mob.getTruePosition()), (MapleMapObject) mob, chr, false, droptype);
                    /*  572 */
                    mesoDropped = true;
                    /*  573 */
                    d = (byte) (d + 1);

                }
                continue;

            }
            /*  576 */
            if (ItemConstants.getInventoryType(de.itemId) == MapleInventoryType.EQUIP) {
                /*  577 */
                Equip equip = ii.randomizeStats((Equip) ii.getEquipById(de.itemId));

            } else {
                /*  579 */
                int range = Math.abs(de.maximum - de.minimum);
                /*  580 */
                idrop = new Item(de.itemId, (short) 0, (short) ((de.maximum != 1) ? (Randomizer.nextInt((range <= 0) ? 1 : range) + de.minimum) : 1), (short) 0);

            }
            /*  582 */
            idrop.setGMLog("怪物掉落: " + mob.getId() + " 地图: " + this.mapid + " 时间: " + DateUtil.getCurrentDate());
            /*  583 */
            if (ItemConstants.isNoticeItem(de.itemId)) {
                /*  584 */
                broadcastMessage(MaplePacketCreator.serverNotice(6, "[掉宝提示] 玩家 " + chr.getName() + " 在 " + chr.getMap().getMapName() + " 杀死 " + mob.getStats().getName() + " 掉落道具 " + ii.getName(de.itemId)));

            }
            /*  586 */
            spawnMobDrop(idrop, calcDropPos(pos, mob.getTruePosition()), mob, chr, droptype, de.questid);
            /*  587 */
            d = (byte) (d + 1);

        }


        /*  591 */
        List<MonsterGlobalDropEntry> globalEntry = new ArrayList<>(mi.getGlobalDrop());
        /*  592 */
        Collections.shuffle(globalEntry);

        /*  594 */
        for (MonsterGlobalDropEntry de : globalEntry) {
            /*  595 */
            if (de.chance == 0) {

                continue;

            }


            /*  600 */
            if (Randomizer.nextInt(999999) < de.chance * globalServerRate)
                 {
                /*  602 */
                if (!this.gDropsDisabled) {
                    /*  603 */
                    Item idrop = new Item();
                    if (droptype == 3) {
                        /*  604 */
                        pos.x = mobpos + ((d % 2 == 0) ? (40 * (d + 1) / 2) : -(40 * d / 2));

                    } else {
                        /*  606 */
                        pos.x = mobpos + ((d % 2 == 0) ? (20 * (d + 1) / 2) : -(20 * d / 2));

                    }
                    /*  608 */
                    if (ItemConstants.getInventoryType(de.itemId) == MapleInventoryType.EQUIP) {
                        /*  609 */
                        Equip equip = ii.randomizeStats((Equip) ii.getEquipById(de.itemId));

                    } else {
                        /*  611 */
                        idrop = new Item(de.itemId, (short) 0, (short) ((de.Maximum != 1) ? (Randomizer.nextInt(de.Maximum - de.Minimum) + de.Minimum) : 1), (short) 0);

                    }
                    /*  613 */
                    idrop.setGMLog("怪物掉落: " + mob.getId() + " 地图: " + this.mapid + " (Global) 时间: " + DateUtil.getCurrentDate());
                    /*  614 */
                    if (ItemConstants.isNoticeItem(de.itemId)) {
                        /*  615 */
                        broadcastMessage(MaplePacketCreator.serverNotice(6, "[掉宝提示] 玩家 " + chr.getName() + " 在 " + chr.getMap().getMapName() + " 杀死 " + mob.getStats().getName() + " 掉落道具 " + ii.getName(de.itemId)));

                    }
                    /*  617 */
                    spawnMobDrop(idrop, calcDropPos(pos, mob.getTruePosition()), mob, chr, de.onlySelf ? 0 : droptype, de.questid);
                    /*  618 */
                    d = (byte) (d + 1);

                }

            }

        }

    }



    public void removeMonster(MapleMonster monster) {
        /*  625 */
        if (monster == null) {

            return;

        }
        /*  628 */
        this.spawnedMonstersOnMap.decrementAndGet();

        /*  630 */
        broadcastMessage(MobPacket.killMonster(monster.getObjectId(), 3));
        /*  631 */
        removeMapObject((MapleMapObject) monster);
        /*  632 */
        monster.killed();

    }



    public void killMonster(MapleMonster monster) {
        /*  636 */
        if (monster == null) {

            return;

        }
        /*  639 */
        this.spawnedMonstersOnMap.decrementAndGet();
        /*  640 */
        monster.setHp(0L);
        /*  641 */
        if (monster.getLinkCID() <= 0) {
            /*  642 */
            monster.spawnRevives(this);

        }
        /*  644 */
        broadcastMessage(MobPacket.killMonster(monster.getObjectId(), (monster.getStats().getSelfD() < 0) ? 1 : monster.getStats().getSelfD()));
        /*  645 */
        removeMapObject((MapleMapObject) monster);
        /*  646 */
        monster.killed();

    }



    public void killMonster(MapleMonster monster, MapleCharacter chr, boolean withDrops, boolean second, byte animation) {
        /*  650 */
        killMonster(monster, chr, withDrops, second, animation, 0);

    }







    public void killMonster(MapleMonster monster, MapleCharacter chr, boolean withDrops, boolean second, byte animation, int lastSkill) {
        /*  658 */
        if ((monster.getId() == 8810122 || monster.getId() == 8810018) && !second) {
            /*  659 */
            Timer.MapTimer.getInstance().schedule(() -> {
                this.killMonster(monster, chr, true, true, (byte) 1);
                this.killAllMonsters(true);
            }, 3000L);




            return;

        }

        /*  665 */
        if (monster.getId() == 8820014) {
            /*  666 */
            killMonster(8820000);
            /*  667 */
        } else if (monster.getId() == 8820212) {
            /*  668 */
            killMonster(8820100);
            /*  669 */
        } else if (monster.getId() == 9300166) {
            /*  670 */
            animation = 2;
            /*  671 */
        } else if ((monster.getId() == 9101083 || monster.getId() == 8880000 || monster.getId() == 8880002) &&
                /*  672 */       chr.getQuestStatus(1463) == 1) {
            /*  673 */
            chr.dropMessage(-1, "由于麦格纳斯死亡时施放出的能量，不再受到古瓦洛的力量的影响。");
            /*  674 */
            MapleQuestStatus quest = chr.getQuest(MapleQuest.getInstance(1463));
            /*  675 */
            quest.setCustomData("001");
            /*  676 */
            chr.updateQuest(quest);

        }

        /*  679 */
        this.spawnedMonstersOnMap.decrementAndGet();
        /*  680 */
        removeMapObject((MapleMapObject) monster);
        /*  681 */
        monster.killed();
        /*  682 */
        MapleSquad sqd = getSquadByMap();
        /*  683 */
        boolean instanced = (sqd != null || monster.getEventInstance() != null || getEMByMap() != null);
        /*  684 */
        int dropOwner = monster.killBy(chr, lastSkill);
        /*  685 */
        if (animation >= 0) {
            /*  686 */
            broadcastMessage(MobPacket.killMonster(monster.getObjectId(), animation));

        }
        /*  688 */
        if (monster.getBuffToGive() > -1) {
            /*  689 */
            int buffid = monster.getBuffToGive();
            /*  690 */
            MapleStatEffect buff = MapleItemInformationProvider.getInstance().getItemEffect(buffid);
            /*  691 */
            this.charactersLock.readLock().lock();

            try {
                /*  693 */
                for (MapleCharacter mc : this.characters) {
                    /*  694 */
                    if (mc.isAlive()) {
                        /*  695 */
                        buff.applyTo(mc);
                        /*  696 */
                        switch (monster.getId()) {

                            case 8810018:

                            case 8810122:

                            case 8820001:

                            case 8820212:
                                /*  701 */
                                mc.getClient().announce(EffectPacket.showOwnBuffEffect(buffid, EffectOpcode.UserEffect_JobChanged.getValue(), mc.getLevel(), 1));
                                /*  702 */
                                broadcastMessage(mc, EffectPacket.showBuffeffect(mc, buffid, EffectOpcode.UserEffect_JobChanged.getValue(), mc.getLevel(), 1), false);

                        }


                    }

                }

            } finally {
                /*  708 */
                this.charactersLock.readLock().unlock();

            }

        }
        /*  711 */
        int mobid = monster.getId();
        /*  712 */
        ExpeditionType type = null;
        /*  713 */
        if (mobid == 8810018 && this.mapid == 240060200) {
            /*  714 */
            WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(6, "经过无数次的挑战，终于击破了暗黑龙王的远征队！你们才是龙之林的真正英雄~"));
            /*  715 */
            this.charactersLock.readLock().lock();

            try {
                /*  717 */
                for (MapleCharacter c : this.characters) {
                    /*  718 */
                    c.finishAchievement(16);

                }

            } finally {
                /*  721 */
                this.charactersLock.readLock().unlock();

            }

            /*  724 */
            if (this.speedRunStart > 0L) {
                /*  725 */
                type = ExpeditionType.Horntail;

            }
            /*  727 */
            doShrine(true);
            /*  728 */
        } else if (mobid == 8810122 && this.mapid == 240060201) {
            /*  729 */
            WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(6, "经过无数次的挑战，终于击破了进阶暗黑龙王的远征队！你们才是龙之林的真正英雄~"));
            /*  730 */
            this.charactersLock.readLock().lock();

            try {
                /*  732 */
                for (MapleCharacter c : this.characters) {
                    /*  733 */
                    c.finishAchievement(24);

                }

            } finally {
                /*  736 */
                this.charactersLock.readLock().unlock();

            }

            /*  739 */
            if (this.speedRunStart > 0L) {
                /*  740 */
                type = ExpeditionType.ChaosHT;

            }
            /*  742 */
            doShrine(true);
            /*  743 */
        } else if (mobid == 9400266 && this.mapid == 802000111) {
            /*  744 */
            doShrine(true);
            /*  745 */
        } else if (mobid == 9400265 && this.mapid == 802000211) {
            /*  746 */
            doShrine(true);
            /*  747 */
        } else if (mobid == 9400270 && this.mapid == 802000411) {
            /*  748 */
            doShrine(true);
            /*  749 */
        } else if (mobid == 9400273 && this.mapid == 802000611) {
            /*  750 */
            doShrine(true);
            /*  751 */
        } else if (mobid == 9400294 && this.mapid == 802000711) {
            /*  752 */
            doShrine(true);
            /*  753 */
        } else if (mobid == 9400296 && this.mapid == 802000803) {
            /*  754 */
            doShrine(true);
            /*  755 */
        } else if (mobid == 9400289 && this.mapid == 802000821) {
            /*  756 */
            doShrine(true);
            /*  757 */
        } else if (mobid == 8830000 && this.mapid == 105100300) {
            /*  758 */
            if (this.speedRunStart > 0L) {
                /*  759 */
                type = ExpeditionType.Normal_Balrog;

            }
            /*  761 */
        } else if ((mobid == 9420544 || mobid == 9420549) && this.mapid == 551030200 && monster.getEventInstance() != null && monster.getEventInstance().getName().contains(getEMByMap().getName())) {
            /*  762 */
            doShrine(getAllReactor().isEmpty());
            /*  763 */
        } else if (mobid == 8820001 && this.mapid == 270050100) {
            /*  764 */
            WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(6, "凭借永不疲倦的热情打败品克缤的远征队啊！你们是真正的时间的胜者！"));
            /*  765 */
            this.charactersLock.readLock().lock();

            try {
                /*  767 */
                for (MapleCharacter c : this.characters) {
                    /*  768 */
                    c.finishAchievement(17);

                }

            } finally {
                /*  771 */
                this.charactersLock.readLock().unlock();

            }
            /*  773 */
            if (this.speedRunStart > 0L) {
                /*  774 */
                type = ExpeditionType.Pink_Bean;

            }
            /*  776 */
            doShrine(true);
            /*  777 */
        } else if (mobid == 8820212 && this.mapid == 270051100) {
            /*  778 */
            WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(6, "凭借永不疲倦的热情打败混沌品克缤的远征队啊！你们是真正的时间的胜者！"));
            /*  779 */
            this.charactersLock.readLock().lock();

            try {
                /*  781 */
                for (MapleCharacter c : this.characters) {
                    /*  782 */
                    c.finishAchievement(59);
                    /*  783 */
                    c.finishActivity(120106);

                }

            } finally {
                /*  786 */
                this.charactersLock.readLock().unlock();

            }
            /*  788 */
            if (this.speedRunStart > 0L) {
                /*  789 */
                type = ExpeditionType.Chaos_Pink_Bean;

            }
            /*  791 */
            doShrine(true);
            /*  792 */
        } else if ((mobid == 8850011 && this.mapid == 271040200) || (mobid == 8850012 && this.mapid == 271040100)) {
            /*  793 */
            WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(6, "被黑魔法师黑化的希纳斯女皇终于被永不言败的远征队打倒! 混沌世界得以净化!"));
            /*  794 */
            this.charactersLock.readLock().lock();

            try {
                /*  796 */
                for (MapleCharacter c : this.characters) {
                    /*  797 */
                    c.finishAchievement(39);

                }

            } finally {
                /*  800 */
                this.charactersLock.readLock().unlock();

            }
            /*  802 */
            if (this.speedRunStart > 0L) {
                /*  803 */
                type = ExpeditionType.Cygnus;

            }
            /*  805 */
            doShrine(true);
            /*  806 */
        } else if (mobid == 8840000 && this.mapid == 211070100) {
            /*  807 */
            this.charactersLock.readLock().lock();

            try {
                /*  809 */
                for (MapleCharacter c : this.characters) {
                    /*  810 */
                    c.finishAchievement(38);

                }

            } finally {
                /*  813 */
                this.charactersLock.readLock().unlock();

            }
            /*  815 */
            if (this.speedRunStart > 0L) {
                /*  816 */
                type = ExpeditionType.Von_Leon;

            }
            /*  818 */
            doShrine(true);
            /*  819 */
        } else if (mobid == 8800002 && (this.mapid == 280030000 || this.mapid == 280030100)) {
            /*  820 */
            this.charactersLock.readLock().lock();

            try {
                /*  822 */
                for (MapleCharacter c : this.characters) {
                    /*  823 */
                    c.finishAchievement(15);
                    /*  824 */
                    c.finishActivity(120105);

                }

            } finally {
                /*  827 */
                this.charactersLock.readLock().unlock();

            }

            /*  830 */
            if (this.speedRunStart > 0L) {
                /*  831 */
                type = ExpeditionType.Zakum;

            }
            /*  833 */
            doShrine(true);
            /*  834 */
        } else if (mobid == 8800102 && this.mapid == 280030001) {
            /*  835 */
            this.charactersLock.readLock().lock();

            try {
                /*  837 */
                for (MapleCharacter c : this.characters) {
                    /*  838 */
                    c.finishAchievement(23);

                }

            } finally {
                /*  841 */
                this.charactersLock.readLock().unlock();

            }

            /*  844 */
            if (this.speedRunStart > 0L) {
                /*  845 */
                type = ExpeditionType.Chaos_Zakum;

            }
            /*  847 */
            doShrine(true);
            /*  848 */
        } else if (mobid == 8870000 && this.mapid == 262031300) {
            /*  849 */
            this.charactersLock.readLock().lock();

            try {
                /*  851 */
                for (MapleCharacter c : this.characters) {
                    /*  852 */
                    c.finishAchievement(55);

                }

            } finally {
                /*  855 */
                this.charactersLock.readLock().unlock();

            }
            /*  857 */
            if (this.speedRunStart > 0L) {
                /*  858 */
                type = ExpeditionType.Hillah;

            }
            /*  860 */
            doShrine(true);
            /*  861 */
        } else if (mobid == 8870100 && this.mapid == 262031300) {
            /*  862 */
            this.charactersLock.readLock().lock();

            try {
                /*  864 */
                for (MapleCharacter c : this.characters) {
                    /*  865 */
                    c.finishAchievement(56);

                }

            } finally {
                /*  868 */
                this.charactersLock.readLock().unlock();

            }
            /*  870 */
            if (this.speedRunStart > 0L) {
                /*  871 */
                type = ExpeditionType.Hillah;

            }
            /*  873 */
            doShrine(true);
            /*  874 */
        } else if (mobid == 8860000 && this.mapid == 272030400) {
            /*  875 */
            this.charactersLock.readLock().lock();

            try {
                /*  877 */
                for (MapleCharacter c : this.characters) {
                    /*  878 */
                    c.finishAchievement(58);

                }

            } finally {
                /*  881 */
                this.charactersLock.readLock().unlock();

            }
            /*  883 */
            if (this.speedRunStart > 0L) {
                /*  884 */
                type = ExpeditionType.Akyrum;

            }
            /*  886 */
            doShrine(true);
            /*  887 */
        } else if (mobid >= 8800003 && mobid <= 8800010) {
            /*  888 */
            boolean makeZakReal = true;
            /*  889 */
            Collection<MapleMonster> monsters = getAllMonstersThreadsafe();
            /*  890 */
            for (MapleMonster mons : monsters) {
                /*  891 */
                if (mons.getId() >= 8800003 && mons.getId() <= 8800010) {
                    /*  892 */
                    makeZakReal = false;

                    break;

                }

            }
            /*  896 */
            if (makeZakReal) {
                /*  897 */
                for (MapleMapObject object : monsters) {
                    /*  898 */
                    MapleMonster mons = (MapleMonster) object;
                    /*  899 */
                    if (mons.getId() == 8800000) {
                        /*  900 */
                        Point pos = mons.getTruePosition();
                        /*  901 */
                        killAllMonsters(true);
                        /*  902 */
                        spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8800000), pos);

                        break;

                    }

                }

            }
            /*  907 */
        } else if (mobid >= 8800103 && mobid <= 8800110) {
            /*  908 */
            boolean makeZakReal = true;
            /*  909 */
            Collection<MapleMonster> monsters = getAllMonstersThreadsafe();
            /*  910 */
            for (MapleMonster mons : monsters) {
                /*  911 */
                if (mons.getId() >= 8800103 && mons.getId() <= 8800110) {
                    /*  912 */
                    makeZakReal = false;

                    break;

                }

            }
            /*  916 */
            if (makeZakReal) {
                /*  917 */
                for (MapleMonster mons : monsters) {
                    /*  918 */
                    if (mons.getId() == 8800100) {
                        /*  919 */
                        Point pos = mons.getTruePosition();
                        /*  920 */
                        killAllMonsters(true);
                        /*  921 */
                        spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8800100), pos);

                        break;

                    }

                }

            }
            /*  926 */
        } else if (mobid >= 8800023 && mobid <= 8800030) {
            /*  927 */
            boolean makeZakReal = true;
            /*  928 */
            Collection<MapleMonster> monsters = getAllMonstersThreadsafe();
            /*  929 */
            for (MapleMonster mons : monsters) {
                /*  930 */
                if (mons.getId() >= 8800023 && mons.getId() <= 8800030) {
                    /*  931 */
                    makeZakReal = false;

                    break;

                }

            }
            /*  935 */
            if (makeZakReal) {
                /*  936 */
                for (MapleMonster mons : monsters) {
                    /*  937 */
                    if (mons.getId() == 8800020) {
                        /*  938 */
                        Point pos = mons.getTruePosition();
                        /*  939 */
                        killAllMonsters(true);
                        /*  940 */
                        spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8800022), pos);

                        break;

                    }

                }

            }
            /*  945 */
        } else if (mobid >= 9400903 && mobid <= 9400910) {
            /*  946 */
            boolean makeZakReal = true;
            /*  947 */
            Collection<MapleMonster> monsters = getAllMonstersThreadsafe();
            /*  948 */
            for (MapleMonster mons : monsters) {
                /*  949 */
                if (mons.getId() >= 9400903 && mons.getId() <= 9400910) {
                    /*  950 */
                    makeZakReal = false;

                    break;

                }

            }
            /*  954 */
            if (makeZakReal) {
                /*  955 */
                for (MapleMonster mons : monsters) {
                    /*  956 */
                    if (mons.getId() == 9400900) {
                        /*  957 */
                        Point pos = mons.getTruePosition();
                        /*  958 */
                        killAllMonsters(true);
                        /*  959 */
                        spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9400900), pos);

                        break;

                    }

                }

            }
            /*  964 */
        } else if (mobid == 8820008) {
            /*  965 */
            for (MapleMapObject mmo : getAllMonstersThreadsafe()) {
                /*  966 */
                MapleMonster mons = (MapleMonster) mmo;
                /*  967 */
                if (mons.getLinkOid() != monster.getObjectId()) {
                    /*  968 */
                    killMonster(mons, chr, false, false, animation);

                }

            }

            /*  972 */
        } else if (mobid >= 8820010 && mobid <= 8820014) {
            /*  973 */
            for (MapleMapObject mmo : getAllMonstersThreadsafe()) {
                /*  974 */
                MapleMonster mons = (MapleMonster) mmo;
                /*  975 */
                if (mons.getId() != 8820000 && mons.getId() != 8820001 && mons.getObjectId() != monster.getObjectId() && mons.isAlive() && mons.getLinkOid() == monster.getObjectId()) {
                    /*  976 */
                    killMonster(mons, chr, false, false, animation);

                }

            }

            /*  980 */
        } else if (mobid == 8820108) {
            /*  981 */
            for (MapleMapObject mmo : getAllMonstersThreadsafe()) {
                /*  982 */
                MapleMonster mons = (MapleMonster) mmo;
                /*  983 */
                if (mons.getLinkOid() != monster.getObjectId()) {
                    /*  984 */
                    killMonster(mons, chr, false, false, animation);

                }

            }

            /*  988 */
        } else if (mobid >= 8820300 && mobid <= 8820304) {
            /*  989 */
            for (MapleMapObject mmo : getAllMonstersThreadsafe()) {
                /*  990 */
                MapleMonster mons = (MapleMonster) mmo;
                /*  991 */
                if (mons.getId() != 8820100 && mons.getId() != 8820212 && mons.getObjectId() != monster.getObjectId() && mons.isAlive() && mons.getLinkOid() == monster.getObjectId()) {
                    /*  992 */
                    killMonster(mons, chr, false, false, animation);

                }

            }

            /*  996 */
        } else if (mobid / 100000 == 98 && chr.getMapId() / 10000000 == 95 && getAllMonstersThreadsafe().isEmpty()) {
            /*  997 */
            switch (chr.getMapId() % 1000 / 100) {

                case 0:

                case 1:

                case 2:

                case 3:

                case 4:
                    /* 1003 */
                    chr.send(UIPacket.showMapEffect("monsterPark/clear"));

                    break;

                case 5:
                    /* 1006 */
                    if (chr.getMapId() / 1000000 == 952) {
                        /* 1007 */
                        chr.send(UIPacket.showMapEffect("monsterPark/clearF"));
                        break;

                    }
                    /* 1009 */
                    chr.send(UIPacket.showMapEffect("monsterPark/clear"));

                    break;


                case 6:
                    /* 1013 */
                    chr.send(UIPacket.showMapEffect("monsterPark/clearF"));

                    break;

            }
            /* 1016 */
        } else if (mobid / 100000 == 93 && chr.getMapId() / 1000000 == 955 && getAllMonstersThreadsafe().isEmpty()) {
            /* 1017 */
            switch (chr.getMapId() % 1000 / 100) {

                case 1:

                case 2:
                    /* 1020 */
                    chr.send(MaplePacketCreator.showEffect("aswan/clear"));
                    /* 1021 */
                    chr.send(MaplePacketCreator.playSound("Party1/Clear"));

                    break;

                case 3:
                    /* 1024 */
                    chr.send(MaplePacketCreator.showEffect("aswan/clearF"));
                    /* 1025 */
                    chr.send(MaplePacketCreator.playSound("Party1/Clear"));
                    /* 1026 */
                    chr.dropMessage(-1, "你已经通过了所有回合。请通过传送口移动到外部。");

                    break;

            }

        }
        /* 1030 */
        eventMobkillCheck(mobid, chr);
        /* 1031 */
        if (type != null &&
                /* 1032 */       this.speedRunStart > 0L && this.speedRunLeader.length() > 0) {
            /* 1033 */
            String name = "";
            /* 1034 */
            switch (type.name()) {

                case "Normal_Balrog":
                    /* 1036 */
                    name = "蝙蝠怪";

                    break;

                case "Zakum":
                    /* 1039 */
                    name = "扎昆";

                    break;

                case "Horntail":
                    /* 1042 */
                    name = "暗黑龙王";

                    break;

                case "Pink_Bean":
                    /* 1045 */
                    name = "时间的宠儿－品克缤";

                    break;

                case "Chaos_Pink_Bean":
                    /* 1048 */
                    name = "混沌品克缤";

                    break;

                case "Chaos_Zakum":
                    /* 1051 */
                    name = "进阶扎昆";

                    break;

                case "ChaosHT":
                    /* 1054 */
                    name = "进阶暗黑龙王";

                    break;

                case "Von_Leon":
                    /* 1057 */
                    name = "班·雷昂";

                    break;

                case "Cygnus":
                    /* 1060 */
                    name = "希纳斯女皇";

                    break;

                case "Akyrum":
                    /* 1063 */
                    name = "阿卡伊勒";

                    break;

                case "Hillah":
                    /* 1066 */
                    name = "希拉";

                    break;

            }
            /* 1069 */
            long endTime = System.currentTimeMillis();
            /* 1070 */
            String time = StringUtil.getReadableMillis(this.speedRunStart, endTime);
            /* 1071 */
            broadcastMessage(MaplePacketCreator.serverNotice(5, this.speedRunLeader + "带领的远征队，耗时: " + time + " 击败了 " + name + "!"));
            /* 1072 */
            getRankAndAdd(this.speedRunLeader, time, type, endTime - this.speedRunStart, (sqd == null) ? null : sqd.getMembers());
            /* 1073 */
            endSpeedRun();

        }

        /* 1076 */
        if (monster.getStats().isBoss()) {
            /* 1077 */
            chr.finishActivity(120107);

        }
        /* 1079 */
        if (withDrops) {

            MapleCharacter drop;
            /* 1081 */
            if (dropOwner <= 0) {
                /* 1082 */
                drop = chr;

            } else {
                /* 1084 */
                drop = getCharacterById(dropOwner);
                /* 1085 */
                if (drop == null) {
                    /* 1086 */
                    drop = chr;

                }

            }
            /* 1089 */
            dropFromMonster(drop, monster, instanced);

        }

        /* 1092 */
        if (ServerConfig.CHANNEL_MONSTER_ELITEPROP != 0 &&
                /* 1093 */       Randomizer.nextInt(30000) < ServerConfig.CHANNEL_MONSTER_ELITEPROP && !MapConstants.cangetNXMap(getId()) && !monster.isFake() && !isBossMap() && monster.getEliteGrade() <= 0 && !monster.isBoss() && chr.getEventInstance() == null) {
            /* 1094 */
            MapleMonster eliteMonster = new MapleMonster(MapleLifeFactory.getMonster(monster.getId()));
            /* 1095 */
            Point truePosition = monster.getTruePosition();
            /* 1096 */
            int n5 = (int) (Math.random() * 2.0D) + 1;
            /* 1097 */
            int n6 = (int) (Math.random() * 25.0D) + 112;
            /* 1098 */
            eliteMonster.setEliteGrade(n5);
            /* 1099 */
            eliteMonster.setEliteType(n6);
            /* 1100 */
            eliteMonster.getStats().setChange(true);
            /* 1101 */
            eliteMonster.changeLevel(eliteMonster.getMobLevel() + 5);
            /* 1102 */
            spawnMonsterOnGroundBelow(eliteMonster, truePosition);

        }

    }




    public void eventMobkillCheck(int n2, MapleCharacter player) {
        /* 1108 */
        if (player == null) {

            return;

        }



        /* 1114 */
        EventInstanceManager eim = player.getEventInstance();
        /* 1115 */
        if (n2 / 100000 == 98 && player.getMapId() / 10000000 == 95 && getAllMonstersThreadsafe().isEmpty()) {
            /* 1116 */
            switch (player.getMapId() % 1000 / 100) {

                case 0:

                case 1:

                case 2:

                case 3:

                case 4:
                    /* 1122 */
                    player.send_other(MaplePacketCreator.showEffect("monsterPark/clear"), true);

                    break;


                case 5:
                    /* 1126 */
                    if (player.getMapId() / 1000000 == 952) {
                        /* 1127 */
                        player.send_other(MaplePacketCreator.showEffect("monsterPark/clearF"), true);

                        break;

                    }
                    /* 1130 */
                    player.send_other(MaplePacketCreator.showEffect("monsterPark/clear"), true);

                    break;


                case 6:
                    /* 1134 */
                    player.send_other(MaplePacketCreator.showEffect("monsterPark/clearF"), true);

                    break;

            }
            /* 1137 */
        } else if (n2 / 100000 == 93 && player.getMapId() / 1000000 == 955 && getAllMonstersThreadsafe().isEmpty()) {
            /* 1138 */
            switch (player.getMapId() % 1000 / 100) {

                case 1:

                case 2:
                    /* 1141 */
                    player.send_other(MaplePacketCreator.showEffect("aswan/clear"), true);
                    /* 1142 */
                    player.send_other(MaplePacketCreator.playSound("Party1/Clear"), true);

                    break;


                case 3:
                    /* 1146 */
                    player.send_other(MaplePacketCreator.showEffect("aswan/clearF"), true);
                    /* 1147 */
                    player.send_other(MaplePacketCreator.playSound("Party1/Clear"), true);
                    /* 1148 */
                    player.dropMessage(-1, "你已经通过了所有回合。请通过传送口移动到外部。");

                    break;

            }
            /* 1151 */
        } else if (n2 / 100000 == 93 && player.getMapId() / 10000 == 86301 && getAllMonster().isEmpty()) {
            /* 1152 */
            if (eim != null) {
                /* 1153 */
                eim.setProperty(String.valueOf(getId()), "2");
                /* 1154 */
                player.showPortal("clear", "1");
                /* 1155 */
                eim.broadcastPacket(MaplePacketCreator.sendGhostPoint(String.valueOf(getId()), "2"));
                /* 1156 */
                player.send_other(MaplePacketCreator.showEffect("aswan/clear"), true);
                /* 1157 */
                player.send_other(MaplePacketCreator.playSound("Party1/Clear"), true);

            }
            /* 1159 */
        } else if (n2 / 100000 == 93 && (player.getMapId() == 921160200 || player.getMapId() == 921160400) && getAllMonster().isEmpty()) {
            /* 1160 */
            startMapEffect("请快点移动到下一张地图。", 5120053);
            /* 1161 */
        } else if (n2 / 100000 == 93 && player.getMapId() / 10000 == 24008 && getAllMonster().isEmpty() && eim != null) {
            /* 1162 */
            player.send_other(MaplePacketCreator.showEffect("quest/party/clear"), true);
            /* 1163 */
            player.send_other(MaplePacketCreator.playSound("Party1/Clear"), true);

        }
        /* 1165 */
        boolean bl2 = false;
        /* 1166 */
        switch (player.getMapId()) {

            case 811000100:
                /* 1168 */
                if (eim == null || !getAllMonster().isEmpty()){
                    break;
                }
                if(eim.getProperty("stage1").equals("1")) {
                    /* 1170 */
                    bl2 = true;
                    /* 1171 */
                    eim.setProperty("stage1", "clear");

                    break;

                }
                /* 1174 */
                eim.schedule("stage1Check", 100L);

                break;


            case 811000200:
                /* 1178 */
                if(eim == null || !getAllMonster().isEmpty()){
                    /* 1179 */ break;
                }
                if (eim.getProperty("stage2").equals("5")) {
                    /* 1180 */
                    bl2 = true;
                    /* 1181 */
                    eim.setProperty("stage2", "clear");

                    break;

                }
                /* 1184 */
                eim.schedule("stage2Check", 100L);

                break;


            case 811000300:
                /* 1188 */
                if(eim == null || !getAllMonster().isEmpty()){
                    /* 1189 */ break;
                }
                if(eim.getProperty("stage3").equals("2") && n2 == 9450014) {
                    /* 1190 */
                    bl2 = true;
                    /* 1191 */
                    eim.setProperty("stage3", "clear");

                    break;

                }
                /* 1194 */
                if(!eim.getProperty("stage3").equals("0")){
                    eim.schedule("stage3Check", 100L);

                    break;
                }
                break;


            case 811000400:
                /* 1199 */
                if (eim == null || !getAllMonster().isEmpty()){
                    /* 1200 */ break;
                }
                if (eim.getProperty("stage4").equals("1")) {
                    /* 1201 */
                    bl2 = true;
                    /* 1202 */
                    eim.setProperty("stage4", "clear");

                    break;

                }
                /* 1205 */
                eim.schedule("stage4Check", 100L);

                break;

        }
        /* 1208 */
        if (bl2) {
            /* 1209 */
            player.send_other(MaplePacketCreator.showEffect("aswan/clear"), true);
            /* 1210 */
            player.send_other(MaplePacketCreator.playSound("Party1/Clear"), true);
            /* 1211 */
            player.showPortal("clear2", "1");
            /* 1212 */
            player.showPortal("clear1", "1");
            /* 1213 */
            changeEnvironment("gate", 2);

        }
        /* 1215 */
        if (n2 == 9390611 || n2 == 9390610) {
            /* 1216 */
            player.showPortal("phase3", "1");
            /* 1217 */
            player.showPortal("clear", "1");
            /* 1218 */
        } else if (n2 == 9390600) {
            /* 1219 */
            player.showPortal("phase2-1", "1");
            /* 1220 */
            player.showPortal("phase2-2", "1");
            /* 1221 */
        } else if (n2 == 9390601) {
            /* 1222 */
            player.showPortal("phase3", "1");
            /* 1223 */
        } else if (n2 == 9390612) {
            /* 1224 */
            player.showPortal("clear2", "1");
            /* 1225 */
            player.showPortal("clear1", "1");

        }

    }



    public List<MapleReactor> getAllReactor() {
        /* 1230 */
        return getAllReactorsThreadsafe();

    }



    public List<MapleReactor> getAllReactorsThreadsafe() {

        ArrayList<MapleReactor> ret;
        /* 1235 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        try {
            /* 1237 */
            ret = (ArrayList<MapleReactor>) ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().parallelStream().map(mmo -> (MapleReactor) mmo).collect(Collectors.toCollection(ArrayList::new));

        } finally {
            /* 1239 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();

        }
        /* 1241 */
        return ret;

    }



    public List<MapleRune> getAllRune() {
        /* 1245 */
        return getAllRuneThreadsafe();

    }



    public List<MapleRune> getAllRuneThreadsafe() {

        ArrayList<MapleRune> ret;
        /* 1250 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.RUNE)).readLock().lock();

        try {
            /* 1252 */
            ret = (ArrayList<MapleRune>) ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.RUNE)).values().parallelStream().map(mmo -> (MapleRune) mmo).collect(Collectors.toCollection(ArrayList::new));

        } finally {
            /* 1254 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.RUNE)).readLock().unlock();

        }
        /* 1256 */
        return ret;

    }



    public List<MapleSummon> getAllSummonsThreadsafe() {

        ArrayList<MapleSummon> ret;
        /* 1261 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.SUMMON)).readLock().lock();

        try {
            /* 1263 */
            ret = (ArrayList<MapleSummon>) ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.SUMMON)).values().parallelStream().filter(mmo -> mmo instanceof MapleSummon).map(mmo -> (MapleSummon) mmo).collect(Collectors.toCollection(ArrayList::new));

        } finally {
            /* 1265 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.SUMMON)).readLock().unlock();

        }
        /* 1267 */
        return ret;

    }



    public List<MapleMapObject> getAllDoor() {
        /* 1271 */
        return getAllDoorsThreadsafe();

    }



    public List<MapleMapObject> getAllDoorsThreadsafe() {

        ArrayList<MapleMapObject> ret;
        /* 1276 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.DOOR)).readLock().lock();

        try {
            /* 1278 */
            ret = (ArrayList<MapleMapObject>) ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.DOOR)).values().parallelStream().filter(mmo -> mmo instanceof MapleDoor).collect(Collectors.toCollection(ArrayList::new));

        } finally {
            /* 1280 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.DOOR)).readLock().unlock();

        }
        /* 1282 */
        return ret;

    }



    public List<MapleMapObject> getAllMechDoorsThreadsafe() {

        ArrayList<MapleMapObject> ret;
        /* 1287 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.DOOR)).readLock().lock();

        try {
            /* 1289 */
            ret = (ArrayList<MapleMapObject>) ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.DOOR)).values().parallelStream().filter(mmo -> mmo instanceof MechDoor).collect(Collectors.toCollection(ArrayList::new));

        } finally {
            /* 1291 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.DOOR)).readLock().unlock();

        }
        /* 1293 */
        return ret;

    }



    public List<MapleMapObject> getAllMerchant() {
        /* 1297 */
        return getAllHiredMerchantsThreadsafe();

    }



    public List<MapleMapObject> getAllHiredMerchantsThreadsafe() {
        /* 1301 */
        ArrayList<MapleMapObject> ret = new ArrayList<>();
        /* 1302 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.HIRED_MERCHANT)).readLock().lock();

        try {
            /* 1304 */
            ret.addAll(((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.HIRED_MERCHANT)).values());

        } finally {
            /* 1306 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.HIRED_MERCHANT)).readLock().unlock();

        }
        /* 1308 */
        return ret;

    }



    public List<MapleMonster> getAllMonster() {
        /* 1312 */
        return getAllMonstersThreadsafe(false);

    }



    public List<MapleMonster> getAllMonstersThreadsafe() {
        /* 1316 */
        return getAllMonstersThreadsafe(true);

    }



    public List<MapleMonster> getAllMonstersThreadsafe(boolean filter) {

        ArrayList<MapleMonster> ret;
        /* 1321 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().lock();




        try {
            /* 1326 */
            ret = (ArrayList<MapleMonster>) ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.MONSTER)).values().parallelStream().filter(mmo -> (filter || (!((MapleMonster) mmo).getStats().getName().contains("dummy") && !((MapleMonster) mmo).getStats().isFriendly()))).map(mmo -> (MapleMonster) mmo).collect(Collectors.toCollection(ArrayList::new));


        }
         finally {


            /* 1332 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().unlock();

        }
        /* 1334 */
        return ret;

    }



    public List<Integer> getAllUniqueMonsters() {
        ArrayList<Integer> ret = new ArrayList();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.MONSTER)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject mmo = (MapleMapObject) var2.next();
                int theId = ((MapleMonster) mmo).getId();
                if (!ret.contains(theId)) {
                    ret.add(theId);
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().unlock();
        }

        return ret;

    }



    public void killAllMonsters(boolean animate) {
        /* 1354 */
        for (MapleMapObject monstermo : getAllMonstersThreadsafe()) {
            /* 1355 */
            MapleMonster monster = (MapleMonster) monstermo;
            /* 1356 */
            this.spawnedMonstersOnMap.decrementAndGet();
            /* 1357 */
            monster.setHp(0L);
            /* 1358 */
            broadcastMessage(MobPacket.killMonster(monster.getObjectId(), animate ? 1 : 0));
            /* 1359 */
            removeMapObject((MapleMapObject) monster);
            /* 1360 */
            monster.killed();

        }

    }



    public void killMonster(int monsId) {
        /* 1365 */
        for (MapleMapObject mmo : getAllMonstersThreadsafe()) {
            /* 1366 */
            if (((MapleMonster) mmo).getId() == monsId) {
                /* 1367 */
                this.spawnedMonstersOnMap.decrementAndGet();
                /* 1368 */
                removeMapObject(mmo);
                /* 1369 */
                broadcastMessage(MobPacket.killMonster(mmo.getObjectId(), 1));
                /* 1370 */
                ((MapleMonster) mmo).killed();

                break;

            }

        }

    }



    public String MapDebug_Log() {
        /* 1377 */
        StringBuilder sb = new StringBuilder("Defeat time : ");
        /* 1378 */
        sb.append(DateUtil.getNowTime());
        /* 1379 */
        sb.append(" | Mapid : ").append(this.mapid);
        /* 1380 */
        this.charactersLock.readLock().lock();

        try {
            /* 1382 */
            sb.append(" Users [").append(this.characters.size()).append("] | ");
            /* 1383 */
            for (MapleCharacter mc : this.characters) {
                /* 1384 */
                sb.append(mc.getName()).append(", ");

            }

        } finally {
            /* 1387 */
            this.charactersLock.readLock().unlock();

        }
        /* 1389 */
        return sb.toString();

    }



    public void limitReactor(int rid, int num) {
        List<MapleReactor> toDestroy = new ArrayList();
        Map<Integer, Integer> contained = new LinkedHashMap();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        Iterator var5;
        try {
            var5 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var5.hasNext()) {
                MapleMapObject obj = (MapleMapObject) var5.next();
                MapleReactor mr = (MapleReactor) obj;
                if (contained.containsKey(mr.getReactorId())) {
                    if ((Integer) contained.get(mr.getReactorId()) >= num) {
                        toDestroy.add(mr);
                    } else {
                        contained.put(mr.getReactorId(), (Integer) contained.get(mr.getReactorId()) + 1);
                    }
                } else {
                    contained.put(mr.getReactorId(), 1);
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }

        var5 = toDestroy.iterator();

        while (var5.hasNext()) {
            MapleReactor mr = (MapleReactor) var5.next();
            this.destroyReactor(mr.getObjectId());
        }

    }



    public void destroyReactors(int first, int last) {
        List<MapleReactor> toDestroy = new ArrayList();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        Iterator var4;
        try {
            var4 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var4.hasNext()) {
                MapleMapObject obj = (MapleMapObject) var4.next();
                MapleReactor mr = (MapleReactor) obj;
                if (mr.getReactorId() >= first && mr.getReactorId() <= last) {
                    toDestroy.add(mr);
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }

        var4 = toDestroy.iterator();

        while (var4.hasNext()) {
            MapleReactor mr = (MapleReactor) var4.next();
            this.destroyReactor(mr.getObjectId());
        }


    }



    public void destroyReactor(int oid) {
        /* 1436 */
        MapleReactor reactor = getReactorByOid(oid);
        /* 1437 */
        if (reactor == null) {

            return;

        }
        /* 1440 */
        broadcastMessage(MaplePacketCreator.destroyReactor(reactor));
        /* 1441 */
        reactor.setAlive(false);
        /* 1442 */
        removeMapObject(reactor);
        /* 1443 */
        reactor.setTimerActive(false);

        /* 1445 */
        if (reactor.getDelay() > 0) {
            /* 1446 */
            Timer.MapTimer.getInstance().schedule(() -> respawnReactor(reactor), reactor.getDelay());

        }

    }



    public void reloadReactors() {
        List<MapleReactor> toSpawn = new ArrayList();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        Iterator var2;
        try {
            var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject obj = (MapleMapObject) var2.next();
                MapleReactor reactor = (MapleReactor) obj;
                this.broadcastMessage(MaplePacketCreator.destroyReactor(reactor));
                reactor.setAlive(false);
                reactor.setTimerActive(false);
                toSpawn.add(reactor);
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }

        var2 = toSpawn.iterator();

        while (var2.hasNext()) {
            MapleReactor r = (MapleReactor) var2.next();
            this.removeMapObject(r);
            if (!r.isCustom()) {
                this.respawnReactor(r);
            }
        }

    }








    public void resetReactors() {
        /* 1478 */
        setReactorState((byte) 0);

    }



    public void setReactorState() {
        /* 1482 */
        setReactorState((byte) 1);

    }



    public void setReactorState(byte state) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject obj = (MapleMapObject) var2.next();
                ((MapleReactor) obj).forceHitReactor(state);
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }

    }



    public void setReactorDelay(int state) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject obj = (MapleMapObject) var2.next();
                ((MapleReactor) obj).setDelay(state);
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }

    }







    public void shuffleReactors() {
        /* 1512 */
        shuffleReactors(0, 9999999);

    }



    public void shuffleReactors(int first, int last) {
        List<Point> points = new ArrayList();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        Iterator var4;
        MapleMapObject obj;
        MapleReactor mr;
        try {
            var4 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var4.hasNext()) {
                obj = (MapleMapObject) var4.next();
                mr = (MapleReactor) obj;
                if (mr.getReactorId() >= first && mr.getReactorId() <= last) {
                    points.add(mr.getPosition());
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }

        Collections.shuffle(points);
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        try {
            var4 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var4.hasNext()) {
                obj = (MapleMapObject) var4.next();
                mr = (MapleReactor) obj;
                if (mr.getReactorId() >= first && mr.getReactorId() <= last) {
                    mr.setPosition((Point) points.remove(points.size() - 1));
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }

    }








    public void updateMonsterController(MapleMonster monster) {
        /* 1548 */
        if (monster == null || !monster.isAlive() || monster.getLinkCID() > 0 || monster.getStats().isEscort()) {

            return;

        }
        /* 1551 */
        if (monster.getController() != null) {
            /* 1552 */
            if (monster.getController().getMap() != this || monster.getController().getTruePosition().distanceSq(monster.getTruePosition()) > monster.getRange().doubleValue()) {
                /* 1553 */
                monster.getController().stopControllingMonster(monster);

            }

            return;

        }
        /* 1557 */
        int mincontrolled = -1;
        /* 1558 */
        MapleCharacter newController = null;

        /* 1560 */
        this.charactersLock.readLock().lock();

        try {
            /* 1562 */
            Iterator<MapleCharacter> ltr = this.characters.iterator();

            /* 1564 */
            while (ltr.hasNext()) {
                /* 1565 */
                MapleCharacter chr = ltr.next();
                /* 1566 */
                if (!chr.isHidden() && (chr.getControlledSize() < mincontrolled || mincontrolled == -1)) {
                    /* 1567 */
                    mincontrolled = chr.getControlledSize();
                    /* 1568 */
                    newController = chr;

                }

            }
            /* 1571 */
            if (newController != null) {
                /* 1572 */
                monster.setLastMove();
                /* 1573 */
                monster.switchController(newController, false);

            }

        } finally {
            /* 1576 */
            this.charactersLock.readLock().unlock();

        }

    }












    public MapleMapObject getMapObject(int oid, MapleMapObjectType type) {
        /* 1590 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(type)).readLock().lock();

        try {
            /* 1592 */
            return (MapleMapObject) ((LinkedHashMap) this.mapobjects.get(type)).get(Integer.valueOf(oid));

        } finally {
            /* 1594 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(type)).readLock().unlock();

        }

    }



    public boolean containsNPC(int npcid) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().lock();

        boolean var9;
        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.NPC)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject mapleMapObject = (MapleMapObject) var2.next();
                MapleNPC n = (MapleNPC) mapleMapObject;
                if (n.getId() == npcid) {
                    boolean var5 = true;
                    return var5;
                }
            }

            var9 = false;
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().unlock();
        }

        return var9;

    }



    public MapleNPC getNPCById(int id) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().lock();

        MapleNPC var5;
        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.NPC)).values().iterator();

            MapleNPC n;
            do {
                if (!var2.hasNext()) {
                    return null;
                }

                MapleMapObject mapleMapObject = (MapleMapObject) var2.next();
                n = (MapleNPC) mapleMapObject;
            } while (n.getId() != id);

            var5 = n;
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().unlock();
        }

        return var5;

    }



    public MapleMonster getMonsterById(int id) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().lock();

        try {
            MapleMonster ret = null;
            Iterator var3 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.MONSTER)).values().iterator();

            while (true) {
                if (var3.hasNext()) {
                    MapleMapObject mapleMapObject = (MapleMapObject) var3.next();
                    MapleMonster n = (MapleMonster) mapleMapObject;
                    if (n.getId() != id) {
                        continue;
                    }

                    ret = n;
                }

                MapleMonster var9 = ret;
                return var9;
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().unlock();
        }

    }



    public int countMonsterById(int id) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().lock();

        try {
            int ret = 0;
            Iterator var3 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.MONSTER)).values().iterator();

            while (var3.hasNext()) {
                MapleMapObject mapleMapObject = (MapleMapObject) var3.next();
                MapleMonster n = (MapleMonster) mapleMapObject;
                if (n.getId() == id) {
                    ++ret;
                }
            }

            int var9 = ret;
            return var9;
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().unlock();
        }

    }



    public MapleReactor getReactorById(int id) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        try {
            MapleReactor ret = null;
            Iterator var3 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (true) {
                if (var3.hasNext()) {
                    MapleMapObject mapleMapObject = (MapleMapObject) var3.next();
                    MapleReactor n = (MapleReactor) mapleMapObject;
                    if (n.getReactorId() != id) {
                        continue;
                    }

                    ret = n;
                }

                MapleReactor var9 = ret;
                return var9;
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }

    }










    public MapleMonster getMonsterByOid(int oid) {
        /* 1686 */
        MapleMapObject mmo = getMapObject(oid, MapleMapObjectType.MONSTER);
        /* 1687 */
        if (mmo == null) {
            /* 1688 */
            return null;

        }
        /* 1690 */
        return (MapleMonster) mmo;

    }



    public MapleSummon getSummonByOid(int oid) {
        /* 1694 */
        MapleMapObject mmo = getMapObject(oid, MapleMapObjectType.SUMMON);
        /* 1695 */
        if (mmo == null) {
            /* 1696 */
            return null;

        }
        /* 1698 */
        return (MapleSummon) mmo;

    }



    public MapleNPC getNPCByOid(int oid) {
        /* 1702 */
        MapleMapObject mmo = getMapObject(oid, MapleMapObjectType.NPC);
        /* 1703 */
        if (mmo == null) {
            /* 1704 */
            return null;

        }
        /* 1706 */
        return (MapleNPC) mmo;

    }



    public MapleReactor getReactorByOid(int oid) {
        /* 1710 */
        MapleMapObject mmo = getMapObject(oid, MapleMapObjectType.REACTOR);
        /* 1711 */
        if (mmo == null) {
            /* 1712 */
            return null;

        }
        /* 1714 */
        return (MapleReactor) mmo;

    }



    public MonsterFamiliarObj getFamiliarByOid(int oid) {
        /* 1718 */
        MapleMapObject mmo = getMapObject(oid, MapleMapObjectType.FAMILIAR);
        /* 1719 */
        if (mmo == null) {
            /* 1720 */
            return null;

        }
        /* 1722 */
        return (MonsterFamiliarObj) mmo;

    }



    public MapleMist getMistByOid(int oid) {
        /* 1726 */
        MapleMapObject mmo = getMapObject(oid, MapleMapObjectType.MIST);
        /* 1727 */
        if (mmo == null) {
            /* 1728 */
            return null;

        }
        /* 1730 */
        return (MapleMist) mmo;

    }



    public MapleReactor getReactorByName(String name) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        Iterator var2;
        try {
            var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject obj = (MapleMapObject) var2.next();
                MapleReactor mr = (MapleReactor) obj;
                if (mr.getName().equalsIgnoreCase(name)) {
                    MapleReactor var5 = mr;
                    return var5;
                }
            }

            var2 = null;
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }
        return null;
    }



    public void spawnNpc(int id, Point pos) {
        /* 1749 */
        MapleNPC npc = MapleLifeFactory.getNPC(id, this.mapid);
        /* 1750 */
        npc.setPosition(pos);
        /* 1751 */
        npc.setCy(pos.y);
        /* 1752 */
        npc.setRx0(pos.x + 50);
        /* 1753 */
        npc.setRx1(pos.x - 50);
        /* 1754 */
        npc.setFh(getFootholds().findBelow(pos, false).getId());
        /* 1755 */
        npc.setCustom(true);
        /* 1756 */
        addMapObject((MapleMapObject) npc);
        /* 1757 */
        broadcastMessage(NPCPacket.spawnNPC(npc));

    }



    public void spawnNpcForPlayer(MapleClient c, int id, Point pos) {
        /* 1761 */
        MapleNPC npc = MapleLifeFactory.getNPC(id, this.mapid);
        /* 1762 */
        npc.setPosition(pos);
        /* 1763 */
        npc.setCy(pos.y);
        /* 1764 */
        npc.setRx0(pos.x + 50);
        /* 1765 */
        npc.setRx1(pos.x - 50);
        /* 1766 */
        npc.setOwnerid(c.getPlayer().getId());
        /* 1767 */
        npc.setFh(getFootholds().findBelow(pos, false).getId());
        /* 1768 */
        npc.setCustom(true);
        /* 1769 */
        addMapObject((MapleMapObject) npc);
        /* 1770 */
        c.announce(NPCPacket.spawnNPC(npc));

    }



    public void removeNpc(int npcid) {
        /* 1774 */
        removeNpc(npcid, 0);

    }



    public void removeNpc(int npcid, int ownerid) {
        /* 1778 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).writeLock().lock();

        try {
            /* 1780 */
            Iterator<MapleMapObject> itr = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.NPC)).values().iterator();
            /* 1781 */
            while (itr.hasNext()) {
                /* 1782 */
                MapleNPC npc = (MapleNPC) itr.next();
                /* 1783 */
                if (!npc.isCustom() || (npcid != -1 && npc.getId() != npcid) || (npc.getId() != 0 && npc.getOwnerid() != ownerid)){

                }
                /* 1785 */
                if (!npc.isHidden() && !GameConstants.isHideNpc(this.mapid, getId())) {
                    /* 1786 */
                    broadcastMessage(NPCPacket.removeNPCController(npc.getObjectId(), false));

                }
                /* 1788 */
                broadcastMessage(NPCPacket.removeNPC(npc.getObjectId()));
                /* 1789 */
                itr.remove();

            }

        } finally {
            /* 1792 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).writeLock().unlock();

        }

    }



    public void hideNpc(int npcid) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.NPC)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject mapleMapObject = (MapleMapObject) var2.next();
                MapleNPC npc = (MapleNPC) mapleMapObject;
                if (npcid == -1 || npc.getId() == npcid) {
                    this.broadcastMessage(NPCPacket.removeNPCController(npc.getObjectId(), false));
                    this.broadcastMessage(NPCPacket.removeNPC(npc.getObjectId()));
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().unlock();
        }

    }



    public void hideNpc(MapleClient c, int npcid) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().lock();

        try {
            Iterator var3 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.NPC)).values().iterator();

            while (var3.hasNext()) {
                MapleMapObject mapleMapObject = (MapleMapObject) var3.next();
                MapleNPC npc = (MapleNPC) mapleMapObject;
                if (npcid == -1 || npc.getId() == npcid) {
                    c.announce(NPCPacket.removeNPCController(npc.getObjectId(), false));
                    c.announce(NPCPacket.removeNPC(npc.getObjectId()));
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().unlock();
        }

    }



    public void spawnReactorOnGroundBelow(MapleReactor mob, Point pos) {
        /* 1827 */
        mob.setPosition(pos);
        /* 1828 */
        mob.setCustom(true);
        /* 1829 */
        spawnReactor(mob);

    }



    public void spawnMonster_sSack(MapleMonster mob, Point pos, int spawnType) {
        /* 1833 */
        mob.setPosition(calcPointBelow(new Point(pos.x, pos.y - 1)));
        /* 1834 */
        spawnMonster(mob, spawnType);

    }



    public void spawnMonster_Pokemon(MapleMonster mob, Point pos, int spawnType) {
        /* 1838 */
        Point spos = calcPointBelow(new Point(pos.x, pos.y - 1));
        /* 1839 */
        mob.setPosition(spos);
        /* 1840 */
        spawnMonster(mob, spawnType, true);

    }



    public void spawnMonsterOnGroundBelow(MapleMonster mob, Point pos) {
        /* 1844 */
        spawnMonster_sSack(mob, pos, -2);

    }



    public int spawnMonsterWithEffectBelow(MapleMonster mob, Point pos, int effect) {
        /* 1848 */
        Point spos = calcPointBelow(new Point(pos.x, pos.y - 1));
        /* 1849 */
        return spawnMonsterWithEffect(mob, effect, spos);

    }






    public void spawnZakum(int x, int y, long maxhp) {
        /* 1856 */
        Point pos = new Point(x, y);
        /* 1857 */
        MapleMonster mainb = MapleLifeFactory.getMonster(8800000);
        /* 1858 */
        Point spos = calcPointBelow(new Point(pos.x, pos.y - 1));
        /* 1859 */
        mainb.setPosition(spos);
        /* 1860 */
        mainb.setFake(true);
        /* 1861 */
        mainb.getStats().setChange(true);
        /* 1862 */
        mainb.changeLevel(120);
        /* 1863 */
        mainb.getChangedStats().setOHp(maxhp);
        /* 1864 */
        mainb.setHp(maxhp);
        /* 1865 */
        spawnFakeMonster(mainb);

        /* 1867 */
        int[] zakpart = {8800003, 8800004, 8800005, 8800006, 8800007, 8800008, 8800009, 8800010};
        /* 1868 */
        for (int i : zakpart) {
            /* 1869 */
            MapleMonster part = MapleLifeFactory.getMonster(i);
            /* 1870 */
            part.changeLevel(120);
            /* 1871 */
            part.getStats().setChange(true);
            /* 1872 */
            part.setPosition(spos);
            /* 1873 */
            spawnMonster(part, -2);

        }
        /* 1875 */
        if (this.squadSchedule != null) {
            /* 1876 */
            cancelSquadSchedule(false);

        }

    }






    public void spawnChaosZakum(int x, int y, long maxhp) {
        /* 1884 */
        Point pos = new Point(-10, -215);
        /* 1885 */
        MapleMonster mainb = MapleLifeFactory.getMonster(8800100);
        /* 1886 */
        Point spos = calcPointBelow(new Point(pos.x, pos.y - 1));
        /* 1887 */
        mainb.setPosition(spos);
        /* 1888 */
        mainb.setFake(true);
        /* 1889 */
        mainb.getStats().setChange(true);
        /* 1890 */
        mainb.changeLevel(160);
        /* 1891 */
        if (maxhp > 0L) {
            /* 1892 */
            mainb.getChangedStats().setOHp(maxhp);
            /* 1893 */
            mainb.setHp(maxhp);

        }
        /* 1895 */
        spawnFakeMonster(mainb);

        /* 1897 */
        int[] zakpart = {8800103, 8800104, 8800105, 8800106, 8800107, 8800108, 8800109, 8800110};
        /* 1898 */
        for (int i : zakpart) {
            /* 1899 */
            MapleMonster part = MapleLifeFactory.getMonster(i);
            /* 1900 */
            part.setPosition(spos);
            /* 1901 */
            spawnMonster(part, -2);

        }
        /* 1903 */
        if (this.squadSchedule != null) {
            /* 1904 */
            cancelSquadSchedule(false);

        }

    }



    public final void spawnSimpleZakum(int x, int y, long maxhp) {
        /* 1909 */
        Point point = new Point(-10, -215);
        /* 1910 */
        MapleMonster mainb = MapleLifeFactory.getMonster(8800020);
        /* 1911 */
        Point calcPointBelow = calcPointBelow(new Point(point.x, point.y - 1));
        /* 1912 */
        mainb.setPosition(calcPointBelow);
        /* 1913 */
        mainb.setFake(true);
        /* 1914 */
        if (maxhp > 0L) {
            /* 1915 */
            mainb.changeLevel(55);
            /* 1916 */
            mainb.getStats().setChange(true);
            /* 1917 */
            mainb.getChangedStats().setOHp(maxhp);
            /* 1918 */
            mainb.setHp(maxhp);

        }
        /* 1920 */
        spawnFakeMonster(mainb);
        /* 1921 */
        int[] zakpart = {8800023, 8800024, 8800025, 8800026, 8800027, 8800028, 8800029, 8800030};
        /* 1922 */
        for (int length = zakpart.length, i = 0; i < length; i++) {
            /* 1923 */
            MapleMonster part = MapleLifeFactory.getMonster(zakpart[i]);
            /* 1924 */
            part.setPosition(calcPointBelow);
            /* 1925 */
            spawnMonster(part, -2);

        }
        /* 1927 */
        if (this.squadSchedule != null) {
            /* 1928 */
            cancelSquadSchedule(false);

        }

    }






    public void spawnPinkZakum(int x, int y) {
        /* 1936 */
        Point pos = new Point(x, y);
        /* 1937 */
        MapleMonster mainb = MapleLifeFactory.getMonster(9400900);
        /* 1938 */
        Point spos = calcPointBelow(new Point(pos.x, pos.y - 1));
        /* 1939 */
        mainb.setPosition(spos);
        /* 1940 */
        mainb.setFake(true);

        /* 1942 */
        spawnFakeMonster(mainb);
        /* 1943 */
        int[] zakpart = {9400903, 9400904, 9400905, 9400906, 9400907, 9400908, 9400909, 9400910};
        /* 1944 */
        for (int i : zakpart) {
            /* 1945 */
            MapleMonster part = MapleLifeFactory.getMonster(i);
            /* 1946 */
            part.setPosition(spos);
            /* 1947 */
            spawnMonster(part, -2);

        }
        /* 1949 */
        if (this.squadSchedule != null) {
            /* 1950 */
            cancelSquadSchedule(false);

        }

    }



    public void spawnFakeMonsterOnGroundBelow(MapleMonster mob, Point pos) {
        /* 1955 */
        Point spos = calcPointBelow(new Point(pos.x, pos.y - 1));
        /* 1956 */
        spos.y--;
        /* 1957 */
        mob.setPosition(spos);
        /* 1958 */
        spawnFakeMonster(mob);

    }



    private void checkRemoveAfter(MapleMonster monster) {
        /* 1962 */
        int ra = monster.getStats().getRemoveAfter();
        /* 1963 */
        if (ra > 0 && monster.getLinkCID() <= 0) {
            /* 1964 */
            monster.registerKill((ra * 1000));

        }

    }



    public void spawnRevives(MapleMonster monster, int oid) {
        /* 1969 */
        monster.setMap(this);
        /* 1970 */
        checkRemoveAfter(monster);
        /* 1971 */
        if (monster.getId() == 9300166) {
            /* 1972 */
            Timer.MapTimer.getInstance().schedule(() -> broadcastMessage(MobPacket.killMonster(monster.getObjectId(), 2)), 3000L);

        }
        /* 1974 */
        monster.setLinkOid(oid);
        /* 1975 */
        spawnAndAddRangedMapObject((MapleMapObject) monster, c -> c.announce(MobPacket.spawnMonster(monster, (monster.getStats().getSummonType() <= 1) ? -3 : monster.getStats().getSummonType(), oid)));


        /* 1978 */
        updateMonsterController(monster);
        /* 1979 */
        this.spawnedMonstersOnMap.incrementAndGet();

    }



    public void spawnMonster(MapleMonster monster, int spawnType) {
        /* 1983 */
        spawnMonster(monster, spawnType, false);

    }



    public void spawnMonster(MapleMonster monster, int spawnType, boolean overwrite) {
        /* 1987 */
        if (monster.getMap() == null && monster.getStats().isHasRange()) {
            /* 1988 */
            monster.setPatrolScopeX1((monster.getPosition()).x);
            /* 1989 */
            monster.setPatrolScopeX2((monster.getPosition()).x + monster.getStats().getRange());

        }

        /* 1992 */
        monster.setMap(this);
        /* 1993 */
        checkRemoveAfter(monster);
        /* 1994 */
        if (monster.getId() == 9300166) {
            /* 1995 */
            Timer.MapTimer.getInstance().schedule(() -> broadcastMessage(MobPacket.killMonster(monster.getObjectId(), 2)), 3000L);

        }
        /* 1997 */
        spawnAndAddRangedMapObject((MapleMapObject) monster, c -> c.announce(MobPacket.spawnMonster(monster,
                /* 1998 */             (monster.getStats().getSummonType() <= 1 || monster.getStats().getSummonType() == 27 || overwrite) ? spawnType : monster.getStats().getSummonType(), 0)));


        /* 2001 */
        updateMonsterController(monster);
        /* 2002 */
        this.spawnedMonstersOnMap.incrementAndGet();

    }



    public int spawnMonsterWithEffect(MapleMonster monster, int effect, Point pos) {

        try {
            /* 2007 */
            monster.setMap(this);
            /* 2008 */
            monster.setPosition(pos);
            /* 2009 */
            spawnAndAddRangedMapObject((MapleMapObject) monster, c -> c.announce(MobPacket.spawnMonster(monster, effect, 0)));
            /* 2010 */
            updateMonsterController(monster);
            /* 2011 */
            this.spawnedMonstersOnMap.incrementAndGet();
            /* 2012 */
            return monster.getObjectId();
            /* 2013 */
        } catch (Exception e) {
            /* 2014 */
            return -1;

        }

    }



    public void spawnFakeMonster(MapleMonster monster) {
        /* 2019 */
        monster.setMap(this);
        /* 2020 */
        monster.setFake(true);
        /* 2021 */
        spawnAndAddRangedMapObject((MapleMapObject) monster, c -> c.announce(MobPacket.spawnMonster(monster, -4, 0)));
        /* 2022 */
        updateMonsterController(monster);
        /* 2023 */
        this.spawnedMonstersOnMap.incrementAndGet();

    }



    public void spawnReactor(MapleReactor reactor) {
        /* 2027 */
        reactor.setMap(this);
        /* 2028 */
        spawnAndAddRangedMapObject(reactor, c -> c.announce(MaplePacketCreator.spawnReactor(reactor)));

    }



    private void respawnReactor(MapleReactor reactor) {
        /* 2032 */
        if (!isSecretMap() && reactor.getReactorId() >= 100000 && reactor.getReactorId() <= 200011) {
            /* 2033 */
            int newRid = ((reactor.getReactorId() < 200000) ? 100000 : 200000) + Randomizer.nextInt(11);
            /* 2034 */
            int prop = reactor.getReactorId() % 100;
            /* 2035 */
            if (Randomizer.nextInt(22) <= prop && newRid % 100 < 10) {
                /* 2036 */
                newRid++;

            }
            /* 2038 */
            if (Randomizer.nextInt(110) <= prop && newRid % 100 < 11) {
                /* 2039 */
                newRid++;

            }
            /* 2041 */
            List<Point> toSpawnPos = new ArrayList<>(this.spawnPoints);
            /* 2042 */
            for (MapleMapObject reactor1l : getAllReactorsThreadsafe()) {
                /* 2043 */
                MapleReactor reactor2l = (MapleReactor) reactor1l;
                /* 2044 */
                if (!toSpawnPos.isEmpty() && toSpawnPos.contains(reactor2l.getPosition())) {
                    /* 2045 */
                    toSpawnPos.remove(reactor2l.getPosition());

                }

            }


            /* 2050 */
            MapleReactor newReactor = new MapleReactor(MapleReactorFactory.getReactor(newRid), newRid);
            /* 2051 */
            newReactor.setPosition(toSpawnPos.isEmpty() ? reactor.getPosition() : toSpawnPos.get(Randomizer.nextInt(toSpawnPos.size())));
            /* 2052 */
            newReactor.setDelay((newRid % 100 == 11) ? 60000 : 5000);
            /* 2053 */
            spawnReactor(newReactor);

        } else {

            /* 2056 */
            reactor.setState((byte) 0);
            /* 2057 */
            reactor.setAlive(true);
            /* 2058 */
            spawnReactor(reactor);

        }

    }



    public void spawnRune(MapleRune rune) {
        /* 2063 */
        rune.setMap(this);

        /* 2065 */
        spawnAndAddRangedMapObject(rune, c -> {

            rune.sendSpawnData(c);

            c.announce(MaplePacketCreator.enableActions());

        });

    }



    public void respawnRune() {
        /* 2072 */
        if (getCharactersSize() > 0) {
            /* 2073 */
            if (System.currentTimeMillis() - this.spawnRuneTime > 300000L) {
                /* 2074 */
                List<Point> spawnPos = new ArrayList<>(this.spawnPoints);
                /* 2075 */
                MapleRune ag2 = new MapleRune((int) (Math.random() * 9.0D));
                /* 2076 */
                for (MapleReactor y2 : getAllReactorsThreadsafe()) {
                    /* 2077 */
                    if (spawnPos.isEmpty() || !spawnPos.contains(y2.getPosition())){
                        spawnPos.remove(y2.getPosition());
                    }
                        /* 2078 */ continue;


                }
                /* 2080 */
                if (!spawnPos.isEmpty()) {
                    /* 2081 */
                    ag2.setPosition(spawnPos.get(Randomizer.nextInt(spawnPos.size())));
                    /* 2082 */
                    spawnRune(ag2);
                    /* 2083 */
                    setRuneTime();

                }

            }

        } else {
            /* 2087 */
            setRuneTime();

        }

    }



    public void setRuneTime() {
        /* 2092 */
        this.spawnRuneTime = System.currentTimeMillis();

    }



    public void removeRune(MapleRune rune) {
        /* 2096 */
        removeMapObject(rune);
        /* 2097 */
        broadcastMessage(MaplePacketCreator.removeRune(rune));

    }



    public boolean isSecretMap() {
        /* 2101 */
        switch (this.mapid) {

            case 910001001:

            case 910001002:

            case 910001003:

            case 910001004:

            case 910001005:

            case 910001006:

            case 910001007:

            case 910001008:

            case 910001009:

            case 910001010:
                /* 2112 */
                return true;

        }
        /* 2114 */
        return false;

    }




    public void spawnDoor(MapleDoor door) {
        /* 2119 */
        spawnAndAddRangedMapObject(door, c -> {

            door.sendSpawnData(c);

            c.announce(MaplePacketCreator.enableActions());

        });

    }



    public void spawnMechDoor(MechDoor door) {
        /* 2126 */
        spawnAndAddRangedMapObject(door, c -> {

            c.announce(MaplePacketCreator.spawnMechDoor(door, true));

            c.announce(MaplePacketCreator.enableActions());

        });

    }








    public void spawnSummon(MapleSummon summon) {
        /* 2138 */
        summon.updateMap(this);
        /* 2139 */
        spawnAndAddRangedMapObject(summon, c -> {

            if (!summon.isChangedMap() || summon.getOwnerId() == c.getPlayer().getId()) {

                summon.sendSpawnData(c);

            }

        });

    }



    public void spawnFamiliar(MonsterFamiliarObj familiar) {
        /* 2147 */
        spawnAndAddRangedMapObject((MapleMapObject) familiar, c -> {

            if (familiar != null && c.getPlayer() != null) {

                familiar.sendSpawnData(c);

            }

        });

    }



    public void spawnExtractor(MapleExtractor ex) {
        /* 2155 */
        spawnAndAddRangedMapObject(ex, ex::sendSpawnData);

    }



    public void spawnLove(MapleLove love) {
        love.getClass();
        this.spawnAndAddRangedMapObject(love, love::sendSpawnData);
        Timer.MapTimer tMan = Timer.MapTimer.getInstance();
        tMan.schedule(() -> {
            this.broadcastMessage(MaplePacketCreator.removeLove(love.getObjectId(), love.getItemId()));
            this.removeMapObject(love);
        }, 3600000L);

    }






    public void spawnMist(MapleMist mist, int duration, boolean fake) {
        mist.getClass();
        this.spawnAndAddRangedMapObject(mist, mist::sendSpawnData);
        Timer.MapTimer tMan = Timer.MapTimer.getInstance();
        ScheduledFuture<?> poisonSchedule = null;
        if (mist.isPoisonMist() && !mist.isMobMist()) {
            MapleCharacter owner = this.getCharacterById(mist.getOwnerId());
            boolean pvp = owner != null && owner.inPVP();
            poisonSchedule = tMan.register(() -> {
                Iterator var5 = this.getMapObjectsInRect(mist.getBox(), Collections.singletonList(pvp ? MapleMapObjectType.PLAYER : MapleMapObjectType.MONSTER)).iterator();

                while (var5.hasNext()) {
                    MapleMapObject mo = (MapleMapObject) var5.next();
                    if (!pvp && mist.makeChanceResult() && !((MapleMonster) mo).isBuffed(MonsterStatus.MOB_STAT_Poison) && owner != null) {
                        ((MapleMonster) mo).applyStatus(owner, new MonsterStatusEffect(MonsterStatus.MOB_STAT_Poison, 1, mist.getSourceSkill().getId(), (MobSkill) null, false, mist.getSource().getDOTStack()), true, (long) duration, true, mist.getSource());
                    }
                }

            }, 2000L, 2500L);
        } else if (mist.isRecoverMist()) {
            poisonSchedule = tMan.register(() -> {
                Iterator var2 = this.getMapObjectsInRect(mist.getBox(), Collections.singletonList(MapleMapObjectType.PLAYER)).iterator();

                while (var2.hasNext()) {
                    MapleMapObject mo = (MapleMapObject) var2.next();
                    if (mist.makeChanceResult()) {
                        MapleCharacter chr = (MapleCharacter) mo;
                        chr.addHPMP((int) ((double) mist.getSource().getX() * ((double) chr.getStat().getMaxHp() / 100.0D)), (int) ((double) mist.getSource().getX() * ((double) chr.getStat().getMaxMp() / 100.0D)));
                    }
                }

            }, 2000L, 2500L);
        } else if (!mist.isMobMist()) {
            Skill skill = mist.getSourceSkill();
            if (skill != null) {
                MapleStatEffect effect = skill.getEffect(mist.getSkillLevel());
                if (effect != null) {
                    poisonSchedule = tMan.register(() -> {
                        Iterator var3 = this.getMapObjectsInRect(mist.getBox(), Collections.singletonList(MapleMapObjectType.MONSTER)).iterator();

                        while (var3.hasNext()) {
                            MapleMapObject mo = (MapleMapObject) var3.next();
                            if (mist.makeChanceResult() && !effect.getMonsterStati().isEmpty()) {
                                ((MapleMonster) mo).applyNewStatus(effect);
                            }
                        }

                    }, 2000L, 0L);
                }
            }
        }

        mist.setPoisonSchedule(poisonSchedule);
        mist.setSchedule(tMan.schedule(() -> {
            this.removeMapObject(mist);
            this.broadcastMessage(MaplePacketCreator.removeMist(mist.getObjectId(), false));
        }, (long) duration));

    }









    public void disappearingItemDrop(MapleMapObject dropper, MapleCharacter owner, Item item, Point pos) {
        /* 2224 */
        Point droppos = calcDropPos(pos, pos);
        /* 2225 */
        MapleMapItem drop = new MapleMapItem(item, droppos, dropper, owner, (byte) 1, false);
        /* 2226 */
        broadcastMessage(InventoryPacket.dropItemFromMapObject(drop, dropper.getTruePosition(), droppos, (byte) 3), drop.getTruePosition());

    }



    public void spawnMesoDrop(int meso, Point position, MapleMapObject dropper, MapleCharacter owner, boolean playerDrop, byte droptype) {
        /* 2230 */
        Point droppos = calcDropPos(position, position);
        /* 2231 */
        MapleMapItem mdrop = new MapleMapItem(meso, droppos, dropper, owner, droptype, playerDrop);

        /* 2233 */
        spawnAndAddRangedMapObject(mdrop, c -> c.announce(InventoryPacket.dropItemFromMapObject(mdrop, dropper.getTruePosition(), droppos, (byte) 1)));
        /* 2234 */
        if (!this.everlast) {
            /* 2235 */
            mdrop.registerExpire(120000L);
            /* 2236 */
            if (droptype == 0 || droptype == 1) {
                /* 2237 */
                mdrop.registerFFA(30000L);

            }

        }

    }






    public void spawnMesoDropEx(int meso, Point dropfrom, Point dropto, MapleMapObject dropper, MapleCharacter owner, boolean playerDrop, byte droptype) {
        /* 2246 */
        Point droppos = calcDropPos(dropto, dropto);
        /* 2247 */
        if (Randomizer.nextBoolean()) {
            /* 2248 */
            droppos.x -= Randomizer.rand(0, 20);

        } else {
            /* 2250 */
            droppos.x += Randomizer.rand(0, 20);

        }
        /* 2252 */
        MapleMapItem mdrop = new MapleMapItem(meso, droppos, dropper, owner, droptype, playerDrop);

        /* 2254 */
        spawnAndAddRangedMapObject(mdrop, c -> c.announce(InventoryPacket.dropItemFromMapObject(mdrop, dropfrom, droppos, (byte) 1)));

        /* 2256 */
        mdrop.registerExpire(120000L);
        /* 2257 */
        if (droptype == 0 || droptype == 1) {
            /* 2258 */
            mdrop.registerFFA(30000L);

        }

    }



    public void spawnMobMesoDrop(int meso, Point position, MapleMapObject dropper, MapleCharacter owner, boolean playerDrop, byte droptype) {
        /* 2263 */
        MapleMapItem mdrop = new MapleMapItem(meso, position, dropper, owner, droptype, playerDrop);

        /* 2265 */
        spawnAndAddRangedMapObject(mdrop, c -> c.announce(InventoryPacket.dropItemFromMapObject(mdrop, dropper.getTruePosition(), position, (byte) 1)));

        /* 2267 */
        mdrop.registerExpire(120000L);
        /* 2268 */
        if (droptype == 0 || droptype == 1) {
            /* 2269 */
            mdrop.registerFFA(30000L);

        }

    }



    public void spawnMobDrop(Item idrop, Point dropPos, MapleMonster mob, MapleCharacter chr, byte droptype, int questid) {
        /* 2274 */
        MapleMapItem mdrop = new MapleMapItem(idrop, dropPos, (MapleMapObject) mob, chr, droptype, false, questid);

        /* 2276 */
        spawnAndAddRangedMapObject(mdrop, c -> {

            if (c != null && c.getPlayer() != null && (questid <= 0 || c.getPlayer().getQuestStatus(questid) == 1) && (idrop.getItemId() / 10000 != 238 || c.getPlayer().getMonsterBook().getLevelByCard(idrop.getItemId()) >= 2) && mob != null && dropPos != null) {

                c.announce(InventoryPacket.dropItemFromMapObject(mdrop, mob.getTruePosition(), dropPos, (byte) 1));

            }

        });
        /* 2281 */
        if (chr.checkSoulWeapon()) {
            /* 2282 */
            chr.writeSoulPacket();
            /* 2283 */
            chr.checkSoulState(false);

        }

        /* 2286 */
        if (mob != null && mob.getStats().getWeaponPoint() > 0 && JobConstants.is神之子(chr.getJob())) {
            /* 2287 */
            chr.gainWeaponPoint(mob.getStats().getWeaponPoint());

        }

        /* 2290 */
        mdrop.registerExpire(120000L);
        /* 2291 */
        if (droptype == 0 || droptype == 1) {
            /* 2292 */
            mdrop.registerFFA(30000L);

        }
        /* 2294 */
        activateItemReactors(mdrop, chr.getClient());

    }



    public void spawnMobDrop(Item idrop, Point dropPos, MapleMonster mob, MapleCharacter chr, byte droptype, int questid, int skillid) {
        /* 2298 */
        MapleMapItem mdrop = new MapleMapItem(idrop, dropPos, (MapleMapObject) mob, chr, droptype, false, questid);

        /* 2300 */
        spawnAndAddRangedMapObject(mdrop, c -> {

            if (c != null && c.getPlayer() != null && (questid <= 0 || c.getPlayer().getQuestStatus(questid) == 1) && (idrop.getItemId() / 10000 != 238 || c.getPlayer().getMonsterBook().getLevelByCard(idrop.getItemId()) >= 2) && mob != null && dropPos != null) {

                c.announce(InventoryPacket.dropItemFromMapObject(mdrop, mob.getTruePosition(), dropPos, (byte) 1, false, skillid));

            }

        });
        /* 2305 */
        if (chr.checkSoulWeapon()) {
            /* 2306 */
            chr.writeSoulPacket();
            /* 2307 */
            chr.checkSoulState(false);

        }

        /* 2310 */
        if (mob != null && mob.getStats().getWeaponPoint() > 0 && JobConstants.is神之子(chr.getJob())) {
            /* 2311 */
            chr.gainWeaponPoint(mob.getStats().getWeaponPoint());

        }

        /* 2314 */
        mdrop.registerExpire(120000L);
        /* 2315 */
        if (droptype == 0 || droptype == 1) {
            /* 2316 */
            mdrop.registerFFA(30000L);

        }
        /* 2318 */
        activateItemReactors(mdrop, chr.getClient());

    }



    public void spawnRandDrop() {
        if (this.mapid == 910000000 && this.channel == 1) {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().lock();

            label56:
            {
                try {
                    Iterator var1 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.ITEM)).values().iterator();

                    MapleMapObject o;
                    do {
                        if (!var1.hasNext()) {
                            break label56;
                        }

                        o = (MapleMapObject) var1.next();
                    } while (!((MapleMapItem) o).isRandDrop());
                } finally {
                    ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().unlock();
                }

                return;
            }

            Timer.MapTimer.getInstance().schedule(() -> {
                Point pos = new Point(Randomizer.nextInt(800) + 531, -806);
                int theItem = Randomizer.nextInt(1000);
                int itemid;
                if (theItem < 950) {
                    itemid = GameConstants.normalDrops[Randomizer.nextInt(GameConstants.normalDrops.length)];
                } else if (theItem < 990) {
                    itemid = GameConstants.rareDrops[Randomizer.nextInt(GameConstants.rareDrops.length)];
                } else {
                    itemid = GameConstants.superDrops[Randomizer.nextInt(GameConstants.superDrops.length)];
                }

                this.spawnAutoDrop(itemid, pos);
            }, 20000L);
        }

    }















    public void spawnAutoDrop(int itemid, Point pos) {

        Item idrop = new Item();
        /* 2353 */
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        /* 2354 */
        if (ItemConstants.getInventoryType(itemid) == MapleInventoryType.EQUIP) {
            /* 2355 */
            Equip equip = ii.randomizeStats((Equip) ii.getEquipById(itemid));

        } else {
            /* 2357 */
            idrop = new Item(itemid, (short) 0, (short) 1, (short) 0);

        }
        /* 2359 */
        idrop.setGMLog("自动掉落 " + itemid + " 地图 " + this.mapid);
        /* 2360 */
        MapleMapItem mdrop = new MapleMapItem(pos, idrop);
        /* 2361 */
        spawnAndAddRangedMapObject(mdrop, c -> c.announce(InventoryPacket.dropItemFromMapObject(mdrop, pos, pos, (byte) 1)));
        /* 2362 */
        broadcastMessage(InventoryPacket.dropItemFromMapObject(mdrop, pos, pos, (byte) 0));
        /* 2363 */
        if (itemid / 10000 != 291) {
            /* 2364 */
            mdrop.registerExpire(120000L);

        }

    }



    public void spawnItemDrop(MapleMapObject dropper, MapleCharacter owner, Item item, Point pos, boolean ffaDrop, boolean playerDrop) {
        /* 2369 */
        Point droppos = calcDropPos(pos, pos);
        /* 2370 */
        MapleMapItem drop = new MapleMapItem(item, droppos, dropper, owner, (byte) 2, playerDrop);

        /* 2372 */
        spawnAndAddRangedMapObject(drop, c -> c.announce(InventoryPacket.dropItemFromMapObject(drop, dropper.getTruePosition(), droppos, (byte) 1)));
        /* 2373 */
        broadcastMessage(InventoryPacket.dropItemFromMapObject(drop, dropper.getTruePosition(), droppos, (byte) 0));

        /* 2375 */
        if (!this.everlast) {
            /* 2376 */
            drop.registerExpire(120000L);
            /* 2377 */
            activateItemReactors(drop, owner.getClient());

        }

    }



    private void activateItemReactors(MapleMapItem drop, MapleClient c) {
        Item item = drop.getItem();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().lock();

        try {
            Iterator var4 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.REACTOR)).values().iterator();

            while (var4.hasNext()) {
                MapleMapObject o = (MapleMapObject) var4.next();
                MapleReactor react = (MapleReactor) o;
                if (react.getReactorType() == 100 && item.getItemId() == GameConstants.getCustomReactItem(react.getReactorId(), (Integer) react.getReactItem().getLeft()) && (Integer) react.getReactItem().getRight() == item.getQuantity() && react.getArea().contains(drop.getTruePosition()) && !react.isTimerActive()) {
                    Timer.MapTimer.getInstance().schedule(new ActivateItemReactor(drop, react, c), 5000L);
                    react.setTimerActive(true);
                    break;
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.REACTOR)).readLock().unlock();
        }


    }



    public int getItemsSize() {
        /* 2407 */
        return ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.ITEM)).size();

    }



    public int getExtractorSize() {
        /* 2411 */
        return ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.EXTRACTOR)).size();

    }



    public int getMobsSize() {
        /* 2415 */
        return ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.MONSTER)).size();

    }



    public int getRunesSize() {
        /* 2419 */
        return ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.RUNE)).size();

    }



    public List<MapleMapItem> getAllItems() {
        /* 2423 */
        return getAllItemsThreadsafe();

    }



    public List<MapleMapItem> getAllItemsThreadsafe() {
        ArrayList<MapleMapItem> ret = new ArrayList();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.ITEM)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject mmo = (MapleMapObject) var2.next();
                ret.add((MapleMapItem) mmo);
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().unlock();
        }

        return ret;

    }



    public Point getPointOfItem(int itemid) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().lock();

        Point var5;
        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.ITEM)).values().iterator();

            MapleMapItem mm;
            do {
                if (!var2.hasNext()) {
                    return null;
                }

                MapleMapObject mmo = (MapleMapObject) var2.next();
                mm = (MapleMapItem) mmo;
            } while (mm.getItem() == null || mm.getItem().getItemId() != itemid);

            var5 = mm.getPosition();
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().unlock();
        }

        return var5;

    }



    public List<MapleMist> getAllMistsThreadsafe() {
        ArrayList<MapleMist> ret = new ArrayList();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MIST)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.MIST)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject mmo = (MapleMapObject) var2.next();
                ret.add((MapleMist) mmo);
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MIST)).readLock().unlock();
        }

        return ret;

    }



    public void returnEverLastItem(MapleCharacter chr) {
        /* 2468 */
        for (MapleMapObject o : getAllItemsThreadsafe()) {
            /* 2469 */
            MapleMapItem item = (MapleMapItem) o;
            /* 2470 */
            if (item.getOwner() == chr.getId()) {
                /* 2471 */
                item.setPickedUp(true);
                /* 2472 */
                broadcastMessage(InventoryPacket.removeItemFromMap(item.getObjectId(), 2, chr.getId()), item.getTruePosition());
                /* 2473 */
                if (item.getMeso() > 0) {
                    /* 2474 */
                    chr.gainMeso(item.getMeso(), false);

                } else {
                    /* 2476 */
                    MapleInventoryManipulator.addFromDrop(chr.getClient(), item.getItem(), false);

                }
                /* 2478 */
                removeMapObject(item);

            }

        }

    }



    public void talkMonster(MapleNodes.MapleStopInfo stopInfo, int id, int oid) {
        /* 2484 */
        if (id > 0) {
            /* 2485 */
            startMapEffect((String) ((Pair) stopInfo.sayInfo.get(stopInfo.isRandom ? 0 : 0)).right, id, false);

        }
        /* 2487 */
        int type = 0;
        /* 2488 */
        switch ((String) ((Pair) stopInfo.sayInfo.get(stopInfo.isRandom ? 0 : 0)).left) {

            case "say":
                /* 2490 */
                type = 49;

                break;


            case "attack1":
                /* 2494 */
                type = 13;

                break;

        }
        /* 2497 */
        broadcastMessage(MobPacket.MobEscortStopSay(oid, stopInfo.chatBalloon, 4000, (String) ((Pair) stopInfo.sayInfo.get(stopInfo.isRandom ? Randomizer.nextInt(stopInfo.sayInfo.size()) : 0)).right, type));

    }



    public void nextNodeAction(int mobid, int time) {
        /* 2501 */
        Timer.MapTimer.getInstance().schedule(() -> {
            if (getMonsterById(mobid) != null){
                broadcastMessage(MobPacket.mobEscortStopEndPermmision(getMonsterById(mobid).getObjectId()));
            }
        }, time);

    }







    public void startMapEffect(String msg, int itemId) {
        /* 2509 */
        startMapEffect(msg, itemId, false);

    }



    public void startMapEffect(String msg, int itemId, boolean jukebox) {
        /* 2513 */
        if (this.mapEffect != null) {

            return;

        }
        /* 2516 */
        this.mapEffect = new MapleMapEffect(msg, itemId);
        /* 2517 */
        this.mapEffect.setJukebox(jukebox);
        /* 2518 */
        broadcastMessage(this.mapEffect.makeStartData());
        /* 2519 */
        Timer.MapTimer.getInstance().schedule(() -> {
            if (this.mapEffect != null) {
                broadcastMessage(this.mapEffect.makeDestroyData());
                this.mapEffect = null;
            }
        }, jukebox ? 300000L : 15000L);

    }








    public void startPredictCardMapEffect(String msg, int itemId, int effectType) {
        /* 2528 */
        startMapEffect(msg, itemId, 30, effectType);

    }



    public void startMapEffect(String msg, int itemId, int time) {
        /* 2532 */
        startMapEffect(msg, itemId, time, -1);

    }



    public void startMapEffect(String msg, int itemId, int time, int effectType) {
        /* 2536 */
        if (this.mapEffect != null) {

            return;

        }
        /* 2539 */
        if (time <= 0) {
            /* 2540 */
            time = 5;

        }
        /* 2542 */
        this.mapEffect = new MapleMapEffect(msg, itemId, effectType);
        /* 2543 */
        this.mapEffect.setJukebox(false);
        /* 2544 */
        broadcastMessage(this.mapEffect.makeStartData());
        /* 2545 */
        Timer.MapTimer.getInstance().schedule(() -> {
            if (this.mapEffect != null) {
                broadcastMessage(this.mapEffect.makeDestroyData());
                this.mapEffect = null;
            }
        }, (time * 1000));

    }








    public void startExtendedMapEffect(String msg, int itemId) {
        /* 2554 */
        broadcastMessage(MaplePacketCreator.startMapEffect(msg, itemId, true));
        /* 2555 */
        Timer.MapTimer.getInstance().schedule(() -> {
            broadcastMessage(MaplePacketCreator.removeMapEffect());
            broadcastMessage(MaplePacketCreator.startMapEffect(msg, itemId, false));
        }, 60000L);

    }






    public void startSimpleMapEffect(String msg, int itemId) {
        /* 2562 */
        broadcastMessage(MaplePacketCreator.startMapEffect(msg, itemId, true));

    }









    public final void sendMapEffect(String message, int type, int time) {
        /* 2572 */
        WorldBroadcastService.getInstance().broadcastMessage(UIPacket.getMapEffectMsg(message, type, time * 1000));

    }



    public void showScreenEffect(String s) {
        /* 2576 */
        broadcastMessage(MaplePacketCreator.showSceenEffect(FieldEffectOpcode.Screen.getValue(), s, 0));

    }



    public void showWeatherEffectNotice(String msg, int type, int time) {
        /* 2580 */
        broadcastMessage(UIPacket.getMapEffectMsg(msg, type, time));

    }



    public void playFieldSound(String sound) {
        /* 2584 */
        broadcastMessage(MaplePacketCreator.playSound(sound, 100));

    }




    public void startJukebox(String msg, int itemId) {
        /* 2589 */
        startMapEffect(msg, itemId, true);

    }



    public void addPlayer(MapleCharacter chr) {
        /* 2593 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.PLAYER)).writeLock().lock();

        try {
            /* 2595 */
            ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.PLAYER)).put(chr.getObjectId(), chr);


        } finally {
            /* 2597 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.PLAYER)).writeLock().unlock();

        }
        /* 2599 */
        this.charactersLock.writeLock().lock();

        try {
            /* 2601 */
            this.characters.add(chr);

        } finally {
            /* 2603 */
            this.charactersLock.writeLock().unlock();

        }
        /* 2605 */
        chr.setChangeTime(true);
        /* 2606 */
        if (GameConstants.isTeamMap(this.mapid) && !chr.inPVP()) {
            /* 2607 */
            chr.setTeam(getAndSwitchTeam() ? 0 : 1);

        }
        /* 2609 */
        byte[] packet = MaplePacketCreator.spawnPlayerMapobject(chr);
        /* 2610 */
        if (!chr.isHidden()) {
            /* 2611 */
            broadcastMessage(chr, packet, false);
            /* 2612 */
            if (chr.isIntern() && this.speedRunStart > 0L) {
                /* 2613 */
                endSpeedRun();
                /* 2614 */
                broadcastMessage(MaplePacketCreator.serverNotice(5, "The speed run has ended."));
                /* 2615 */
                broadcastMessage(chr, EffectPacket.getEffectSwitch(chr.getId(), chr.getEffectSwitch()), true);

            }

        } else {
            /* 2618 */
            broadcastGMMessage(chr, packet, false);
            /* 2619 */
            broadcastGMMessage(chr, EffectPacket.getEffectSwitch(chr.getId(), chr.getEffectSwitch()), true);

        }



        /* 2624 */
        chr.send(UIPacket.showFreeMarketMiniMap(false));

        /* 2626 */
        sendObjectPlacement(chr);



        /* 2630 */
        if (!this.onUserEnter.equals("")) {
            /* 2631 */
            MapScriptMethods.startScript_User(chr.getClient(), this.onUserEnter);

        }
        /* 2633 */
        if (!this.onFirstUserEnter.equals("") &&
                /* 2634 */       getCharactersSize() == 1) {
            /* 2635 */
            MapScriptMethods.startScript_FirstUser(chr.getClient(), this.onFirstUserEnter);

        }

        /* 2638 */
        GameConstants.achievementRatio(chr.getClient());

        /* 2640 */
        if (GameConstants.isTeamMap(this.mapid) && !chr.inPVP()) {
            /* 2641 */
            chr.send(MaplePacketCreator.showEquipEffect(chr.getTeam()));

        }
        /* 2643 */
        switch (this.mapid) {

            case 809000101:

            case 809000201:
                /* 2646 */
                chr.send(MaplePacketCreator.showEquipEffect());

                break;

        }
        /* 2649 */
        MaplePet[] pets = chr.getSpawnPets();
        /* 2650 */
        for (int i = 0; i < 3; i++) {
            /* 2651 */
            if (pets[i] != null && pets[i].getSummoned()) {
                /* 2652 */
                pets[i].setPos(chr.getTruePosition());
                /* 2653 */
                chr.petUpdateStats(pets[i], true);
                /* 2654 */
                chr.send(PetPacket.showPet(chr, pets[i], false, false, true));
                /* 2655 */
                chr.send(PetPacket.loadExceptionList(chr, pets[i]));

            }

        }
        /* 2658 */
        if (chr.getAndroid() != null) {
            /* 2659 */
            chr.getAndroid().setPos(chr.getTruePosition());
            /* 2660 */
            broadcastMessage(AndroidPacket.spawnAndroid(chr, chr.getAndroid()));

        }
        /* 2662 */
        if (chr.getParty() != null) {
            /* 2663 */
            chr.silentPartyUpdate();
            /* 2664 */
            chr.send(PartyPacket.updateParty(chr.getClient().getChannel(), chr.getParty(), PartyOperation.更新队伍, null));
            /* 2665 */
            chr.updatePartyMemberHP();
            /* 2666 */
            chr.receivePartyMemberHP();

        }
        /* 2668 */
        if (!chr.isInBlockedMap() && chr.getLevel() > 10) {
            /* 2669 */
            chr.send(MaplePacketCreator.showQuickMove(chr));

        }
        /* 2671 */
        chr.send(NPCPacket.sendNpcHide(this.hideNpc));

        /* 2673 */
        List<MapleSummon> ss = chr.getSummonsReadLock();

        try {
            /* 2675 */
            for (MapleSummon summon : ss) {
                /* 2676 */
                summon.setPosition(chr.getTruePosition());
                /* 2677 */
                chr.addVisibleMapObject(summon);
                /* 2678 */
                spawnSummon(summon);

            }

        } finally {
            /* 2681 */
            chr.unlockSummonsReadLock();

        }
        /* 2683 */
        if (this.mapEffect != null) {
            /* 2684 */
            this.mapEffect.sendStartData(chr.getClient());

        }
        /* 2686 */
        if (this.timeLimit > 0 && getForcedReturnMap() != null) {
            /* 2687 */
            chr.startMapTimeLimitTask(this.timeLimit, getForcedReturnMap());

        }
        /* 2689 */
        if (chr.getBuffedValue(MapleBuffStat.骑兽技能) != null && !JobConstants.is反抗者(chr.getJob()) &&
                /* 2690 */       FieldLimitType.Mount.check(this.fieldLimit)) {
            /* 2691 */
            chr.cancelEffectFromBuffStat(MapleBuffStat.骑兽技能);

        }

        /* 2694 */
        if (chr.getEventInstance() != null && chr.getEventInstance().isTimerStarted()) {
            /* 2695 */
            chr.send(MaplePacketCreator.getClock((int) (chr.getEventInstance().getTimeLeft() / 1000L)));

        }
        /* 2697 */
        if (hasClock()) {
            /* 2698 */
            Calendar cal = Calendar.getInstance();
            /* 2699 */
            chr.send(MaplePacketCreator.getClockTime(cal.get(11), cal.get(12), cal.get(13)));

        }
        /* 2701 */
        if (chr.getEventInstance() != null) {
            /* 2702 */
            chr.getEventInstance().onMapLoad(chr);

        }
        /* 2704 */
        if (getSquadBegin() != null && getSquadBegin().getTimeLeft() > 0L && getSquadBegin().getStatus() == 1) {
            /* 2705 */
            chr.send(MaplePacketCreator.getClock((int) (getSquadBegin().getTimeLeft() / 1000L)));

        }
        /* 2707 */
        if (this.mapid / 1000 != 105100 && this.mapid / 100 != 8020003 && this.mapid / 100 != 8020008 && this.mapid != 271040100) {
            /* 2708 */
            MapleSquad sqd = getSquadByMap();
            /* 2709 */
            EventManager em = getEMByMap();
            /* 2710 */
            if (!this.squadTimer && sqd != null && chr.getName().equals(sqd.getLeaderName()) && em != null && em.getProperty("leader") != null && em.getProperty("leader").equals("true") && this.checkStates) {

                /* 2712 */
                doShrine(false);
                /* 2713 */
                this.squadTimer = true;

            }

        }
        /* 2716 */
        if (getNumMonsters() > 0 && (this.mapid == 280030001 || this.mapid == 240060201 || this.mapid == 280030000 || this.mapid == 280030100 || this.mapid == 240060200 || this.mapid == 220080001 || this.mapid == 541020800 || this.mapid == 541010100)) {
            /* 2717 */
            String music = "Bgm09/TimeAttack";
            /* 2718 */
            switch (this.mapid) {

                case 240060200:

                case 240060201:
                    /* 2721 */
                    music = "Bgm14/HonTale";

                    break;

                case 280030000:

                case 280030001:

                case 280030100:
                    /* 2726 */
                    music = "Bgm06/FinalFight";

                    break;

            }
            /* 2729 */
            chr.send(MaplePacketCreator.musicChange(music));

        }

        /* 2732 */
        if (this.mapid == 914000000 || this.mapid == 927000000) {
            /* 2733 */
            chr.send(MaplePacketCreator.temporaryStats_Aran());
            /* 2734 */
        } else if (this.mapid == 105100300 && chr.getLevel() >= 91) {
            /* 2735 */
            chr.send(MaplePacketCreator.temporaryStats_Balrog(chr));

        }
        /* 2737 */
        chr.send(MaplePacketCreator.temporaryStats_Reset());


        /* 2740 */
        if (chr.getSummonedFamiliar() != null) {
            /* 2741 */
            chr.spawnFamiliar(chr.getSummonedFamiliar().getFamiliar());
            /* 2742 */
            chr.setChanged_familiars(true);

        }

        /* 2745 */
        if (JobConstants.is龙神(chr.getJob()) && chr.getJob() >= 2200) {
            /* 2746 */
            if (chr.getDragon() == null) {
                /* 2747 */
                chr.makeDragon();

            } else {
                /* 2749 */
                chr.getDragon().setPosition(chr.getPosition());

            }
            /* 2751 */
            if (chr.getDragon() != null) {
                /* 2752 */
                broadcastMessage(SummonPacket.spawnDragon(chr.getDragon()));

            }

        }
        /* 2755 */
        if (JobConstants.is阴阳师(chr.getJob())) {
            /* 2756 */
            if (chr.getLittleWhite() == null) {
                /* 2757 */
                chr.makeLittleWhite();

            } else {
                /* 2759 */
                chr.getLittleWhite().setPosition(chr.getPosition());

            }
            /* 2761 */
            if (chr.getLittleWhite() != null) {
                /* 2762 */
                broadcastMessage(SummonPacket.spawnLittleWhite(chr.getLittleWhite()));

            }

        }
        /* 2765 */
        if ((this.mapid == 10000 && chr.getJob() == 0) || (this.mapid == 130030000 && chr.getJob() == 1000) || (this.mapid == 914000000 && chr.getJob() == 2000) || (this.mapid == 900010000 && chr.getJob() == 2001) || (this.mapid == 931000000 && chr.getJob() == 3000)) {
            /* 2766 */
            chr.send(MaplePacketCreator.startMapEffect("欢迎来到 " + chr.getClient().getChannelServer().getServerName() + "!", 5122000, true));
            /* 2767 */
            chr.dropMessage(5, "使用 @help 可以查看你当前能使用的命令 祝你玩的愉快！");

        }
        /* 2769 */
        if (this.permanentWeather > 0) {
            /* 2770 */
            chr.send(MaplePacketCreator.startMapEffect("", this.permanentWeather, false));

        }
        /* 2772 */
        if (getPlatforms().size() > 0) {
            /* 2773 */
            chr.send(MaplePacketCreator.getMovingPlatforms(this));

        }
        /* 2775 */
        if (this.partyBonusRate > 0) ;



        /* 2779 */
        if (isTown()) {
            /* 2780 */
            chr.cancelEffectFromBuffStat(MapleBuffStat.地雷);

        }
        /* 2782 */
        if (!canSoar()) {
            /* 2783 */
            chr.cancelEffectFromBuffStat(MapleBuffStat.飞翔);

        }
        /* 2785 */
        if (chr.getJob() < 3200 || chr.getJob() > 3212) {
            /* 2786 */
            chr.cancelEffectFromBuffStat(MapleBuffStat.战法灵气);

        }
        /* 2788 */
        if (chr.getJob() >= 2400 && chr.getJob() <= 2412) {
            /* 2789 */
            chr.send(MaplePacketCreator.updateCardStack(chr.getCardStack()));

        }

        /* 2792 */
        if (JobConstants.is爆破手(chr.getJob())) {
            /* 2793 */
            chr.hadnleBlasterClip(0);

        }

        /* 2796 */
        if (JobConstants.is冲锋队长(chr.getJob())) {
            /* 2797 */
            Skill echskill_2 = SkillFactory.getSkill(5100015);
            /* 2798 */
            Skill echskill_3 = SkillFactory.getSkill(5110014);
            /* 2799 */
            Skill echskill_4 = SkillFactory.getSkill(5120018);
            /* 2800 */
            MapleStatEffect effect = null;
            /* 2801 */
            if (chr.getSkillLevel(echskill_4) > 0) {
                /* 2802 */
                effect = echskill_4.getEffect(chr.getTotalSkillLevel(echskill_4));
                /* 2803 */
            } else if (chr.getSkillLevel(echskill_3) > 0) {
                /* 2804 */
                effect = echskill_3.getEffect(chr.getTotalSkillLevel(echskill_3));
                /* 2805 */
            } else if (chr.getSkillLevel(echskill_2) > 0) {
                /* 2806 */
                effect = echskill_2.getEffect(chr.getTotalSkillLevel(echskill_2));

            }

            /* 2809 */
            if (chr.getBuffedValue(MapleBuffStat.能量获得) == null) {
                /* 2810 */
                effect.applyEnergyBuff(chr, 0);

            }

        }

        /* 2814 */
        if (isPvpMap()) {
            /* 2815 */
            chr.dropSpouseMessage(10, "[系统提示] 您已进入个人PK地图，请小心。");
            /* 2816 */
        } else if (isPartyPvpMap()) {
            /* 2817 */
            chr.dropSpouseMessage(10, "[系统提示] 您已进入组队PK地图，请小心。");
            /* 2818 */
        } else if (isGuildPvpMap()) {
            /* 2819 */
            chr.dropSpouseMessage(10, "[系统提示] 您已进入家族PK地图，请小心。");

        }

        /* 2822 */
        if (getId() == 450004250) {
            /* 2823 */
            ShowSteps(true);

        }

        /* 2826 */
        chr.checkBloodContract();
        /* 2827 */
        chr.send(MaplePacketCreator.showChronosphere(chr.getBossLog("免费超时空券"), (int) Math.ceil((chr.getCSPoints(2) / 200))));

        /* 2829 */
        if (JobConstants.is御剑骑士(chr.getJob())) {

            /* 2831 */
            List<MapleBlueSkySword> Sword = new ArrayList<>();
            /* 2832 */
            if (chr.getSpecialStat().isDZ1()) {
                /* 2833 */
                for (int j = 0; j < 2; j++) {
                    /* 2834 */
                    Sword.add(new MapleBlueSkySword(chr, 6 + j, 1 + j, 0, 0, 0, 0, chr.getJob(), 0, 1, chr.getPosition()));

                }
                /* 2836 */
                chr.getMap().broadcastMessage(MapleBlueSkySwordPacket.SpawnBlueSkySword(chr.getId(), Sword, 0));

            }

            /* 2839 */
            if (chr.getSpecialStat().isDZ2()) {
                /* 2840 */
                for (int j = 0; j < 2; j++) {
                    /* 2841 */
                    Sword.add(new MapleBlueSkySword(chr, 8 + j, 3 + j, 0, 0, 0, 0, chr.getJob(), 0, 1, chr.getPosition()));

                }
                /* 2843 */
                chr.getMap().broadcastMessage(MapleBlueSkySwordPacket.SpawnBlueSkySword(chr.getId(), Sword, 0));

            }

            /* 2846 */
            if (chr.getJob() == 15112 && chr.getSpecialStat().isDZ3()) {
                /* 2847 */
                for (int j = 0; j < 2; j++) {
                    /* 2848 */
                    Sword.add(new MapleBlueSkySword(chr, 10 + j, 5 + j, 0, 0, 0, 0, chr.getJob(), 0, 1, chr.getPosition()));

                }
                /* 2850 */
                chr.getMap().broadcastMessage(MapleBlueSkySwordPacket.SpawnBlueSkySword(chr.getId(), Sword, 0));

            }

        }

    }







    public int getNumItems() {
        /* 2860 */
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().lock();

        try {
            /* 2862 */
            return ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.ITEM)).size();

        } finally {
            /* 2864 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().unlock();

        }

    }



    public int getNumMonsters() {
        /* 2869 */
        return getNumMonsters(-1);

    }



    public int getNumMonsters(int mobid) {
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().lock();

        int var2;
        try {
            if (mobid == -1) {
                var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.MONSTER)).size();
                return var2;
            }

            return ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.MONSTER)).size();
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.MONSTER)).readLock().unlock();
        }


    }



    public void doShrine(boolean spawned) {
        /* 2886 */
        if (this.squadSchedule != null) {
            /* 2887 */
            cancelSquadSchedule(true);

        }
        /* 2889 */
        MapleSquad sqd = getSquadByMap();
        /* 2890 */
        if (sqd == null) {

            return;

        }
        /* 2893 */
        int mode = (this.mapid == 280030000 || this.mapid == 280030100) ? 1 : ((this.mapid == 280030001) ? 2 : ((this.mapid == 240060200 || this.mapid == 240060201) ? 3 : 0));

        /* 2895 */
        EventManager em = getEMByMap();
        /* 2896 */
        if (em != null && getCharactersSize() > 0) {
            /* 2897 */
            Runnable run;
            String leaderName = sqd.getLeaderName();
            /* 2898 */
            String state = em.getProperty("state");

            /* 2900 */
            MapleMap returnMapa = getForcedReturnMap();
            /* 2901 */
            if (returnMapa == null || returnMapa.getId() == this.mapid) {
                /* 2902 */
                returnMapa = getReturnMap();

            }
            /* 2904 */
            if (mode != 1 && mode != 2)
                 {
                /* 2906 */
                if (mode == 3) {
                }
                ;

            }



            /* 2911 */
            if (spawned) {
                /* 2912 */
                broadcastMessage(MaplePacketCreator.getClock(300));

            }
            /* 2914 */
            MapleMap returnMapz = returnMapa;
            /* 2915 */
            if (!spawned) {
                /* 2916 */
                List<MapleMonster> monsterz = getAllMonstersThreadsafe();
                /* 2917 */
                List<Integer> monsteridz = new ArrayList<>();
                /* 2918 */
                for (MapleMapObject m : monsterz) {
                    /* 2919 */
                    monsteridz.add(Integer.valueOf(m.getObjectId()));

                }
                /* 2921 */
                run = (() -> {

                    MapleSquad sqnow = getSquadByMap();


                    if (getCharactersSize() > 0 && getNumMonsters() == monsterz.size() && sqnow != null && sqnow.getStatus() == 2 && sqnow.getLeaderName().equals(leaderName) && getEMByMap().getProperty("state").equals(state)) {

                        boolean passed = monsterz.isEmpty();


                        for (MapleMapObject m : getAllMonstersThreadsafe()) {

                            Iterator<Integer> iterator = monsteridz.iterator();


                            while (iterator.hasNext()) {

                                int i = ((Integer) iterator.next()).intValue();


                                if (m.getObjectId() == i) {

                                    passed = true;


                                    break;

                                }

                            }


                            if (passed) {

                                break;

                            }

                        }


                        if (passed) {

                            for (MapleCharacter chr : getCharactersThreadsafe()) {

                                chr.changeMap(returnMapz, returnMapz.getPortal(0));

                            }

                            checkStates("");

                            resetFully();

                        }

                    }

                });

            } else {
                /* 2955 */
                run = (() -> {

                    MapleSquad sqnow = getSquadByMap();




                    if (getCharactersSize() > 0 && sqnow != null && sqnow.getStatus() == 2 && sqnow.getLeaderName().equals(leaderName) && getEMByMap().getProperty("state").equals(state)) {

                        for (MapleCharacter chr : getCharactersThreadsafe()) {

                            chr.changeMap(returnMapz, returnMapz.getPortal(0));

                        }



                        checkStates("");



                        resetFully();

                    }

                });

            }


            /* 2975 */
            this.squadSchedule = Timer.MapTimer.getInstance().schedule(run, 300000L);

        }

    }



    public MapleSquad getSquadByMap() {

        MapleSquadType zz;
        /* 2981 */
        switch (this.mapid) {

            case 105100300:

            case 105100400:
                /* 2984 */
                zz = MapleSquadType.bossbalrog;








































































                /* 3057 */
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 280030000:
            case 280030100:
                zz = MapleSquadType.zak;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 280030001:
                zz = MapleSquadType.chaoszak;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 240060200:
                zz = MapleSquadType.horntail;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 240060201:
                zz = MapleSquadType.chaosht;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 270050100:
                zz = MapleSquadType.pinkbean;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 270051100:
                zz = MapleSquadType.chaospb;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 802000111:
                zz = MapleSquadType.nmm_squad;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 802000211:
                zz = MapleSquadType.vergamot;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 802000311:
                zz = MapleSquadType.tokyo_2095;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 802000411:
                zz = MapleSquadType.dunas;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 802000611:
                zz = MapleSquadType.nibergen_squad;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 802000711:
                zz = MapleSquadType.dunas2;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 802000801:
            case 802000802:
            case 802000803:
                zz = MapleSquadType.core_blaze;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 802000821:
            case 802000823:
                zz = MapleSquadType.aufheben;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 211070100:
            case 211070101:
            case 211070110:
                zz = MapleSquadType.vonleon;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 551030200:
                zz = MapleSquadType.scartar;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 271040100:
                zz = MapleSquadType.cygnus;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 689013000:
                zz = MapleSquadType.pinkzak;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 262031300:
            case 262031310:
                zz = MapleSquadType.hillah;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);
            case 272030400:
            case 272030420:
                zz = MapleSquadType.arkarium;
                return ChannelServer.getInstance(this.channel).getMapleSquad(zz);

        }

        return null;

    }

    public MapleSquad getSquadBegin() {
        /* 3061 */
        if (this.squad != null) {
            /* 3062 */
            return ChannelServer.getInstance(this.channel).getMapleSquad(this.squad);

        }
        /* 3064 */
        return null;

    }



    public EventManager getEMByMap() {

        String em;
        /* 3069 */
        switch (this.mapid) {

            case 105100400:
                /* 3071 */
                em = "BossBalrog_EASY";











































































                /* 3147 */
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 105100300:
                em = "BossBalrog_NORMAL";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 280030000:
            case 280030100:
                em = "ZakumBattle";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 240060200:
                em = "HorntailBattle";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 280030001:
                em = "ChaosZakum";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 240060201:
                em = "ChaosHorntail";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 270050100:
                em = "PinkBeanBattle";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 270051100:
                em = "ChaosPinkBean";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 802000111:
                em = "NamelessMagicMonster";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 802000211:
                em = "Vergamot";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 802000311:
                em = "2095_tokyo";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 802000411:
                em = "Dunas";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 802000611:
                em = "Nibergen";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 802000711:
                em = "Dunas2";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 802000801:
            case 802000802:
            case 802000803:
                em = "CoreBlaze";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 802000821:
            case 802000823:
                em = "Aufhaven";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 211070100:
            case 211070101:
            case 211070110:
                em = "VonLeonBattle";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 551030200:
                em = "ScarTarBattle";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 271040100:
                em = "CygnusBattle";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 689013000:
                em = "PinkZakum";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 262031300:
            case 262031310:
                em = "Hillah_170";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);
            case 272030400:
            case 272030420:
                em = "ArkariumBattle";
                return ChannelServer.getInstance(this.channel).getEventSM().getEventManager(em);

        }

        return null;

    }

    public void removePlayer(MapleCharacter chr) {
        /* 3151 */
        if (this.everlast) {
            /* 3152 */
            returnEverLastItem(chr);

        }
        /* 3154 */
        this.charactersLock.writeLock().lock();

        try {
            /* 3156 */
            this.characters.remove(chr);
            /* 3157 */
            if (this.characters.size() <= 1) {
                /* 3158 */
                StringBuilder sb = new StringBuilder();
                /* 3159 */
                this.characters.forEach(player -> sb.append(player.getName()).append(","));

            }

        } finally {

            /* 3163 */
            this.charactersLock.writeLock().unlock();

        }
        /* 3165 */
        removeMapObject((MapleMapObject) chr);
        /* 3166 */
        if (chr.getSummonedFamiliar() != null) {
            /* 3167 */
            disappearMapObject((MapleMapObject) chr.getSummonedFamiliar());

        }
        /* 3169 */
        chr.checkFollow();
        /* 3170 */
        chr.removeExtractor();
        /* 3171 */
        broadcastMessage(MaplePacketCreator.removePlayerFromMap(chr.getId()));

        /* 3173 */
        removeVisibleSummon(chr);
        /* 3174 */
        checkStates(chr.getName());
        /* 3175 */
        if (this.mapid == 109020001) {
            /* 3176 */
            chr.canTalk(true);

        }
        /* 3178 */
        chr.leaveMap(this);

    }








    public void removeVisibleSummon(MapleCharacter chr) {
        /* 3187 */
        List<MapleSummon> toCancel = new ArrayList<>();
        /* 3188 */
        List<MapleSummon> listSummons = chr.getSummonsReadLock();

        try {
            /* 3190 */
            listSummons.forEach(summon -> {

                broadcastMessage(SummonPacket.removeSummon(summon, true));

                removeMapObject(summon);

                chr.removeVisibleMapObject(summon);

                if (summon.isChangeMapCanceled()) {

                    toCancel.add(summon);

                } else {

                    summon.setChangedMap(true);

                }

            });

        } finally {
            /* 3201 */
            chr.unlockSummonsReadLock();

        }
        /* 3203 */
        toCancel.forEach(summon -> {

            chr.removeSummon(summon);

            chr.dispelSkill(summon.getSkillId());

        });

    }



    public void broadcastMessage(byte[] packet) {
        /* 3210 */
        broadcastMessage(null, packet, Double.POSITIVE_INFINITY, null);

    }



    public void broadcastMessage(MapleCharacter source, byte[] packet, boolean repeatToSource) {
        /* 3214 */
        broadcastMessage(repeatToSource ? null : source, packet, Double.POSITIVE_INFINITY, source.getTruePosition());

    }









    public void broadcastMessage(byte[] packet, Point rangedFrom) {
        /* 3224 */
        broadcastMessage(null, packet, GameConstants.maxViewRangeSq().doubleValue(), rangedFrom);

    }



    public void broadcastMessage(MapleCharacter source, byte[] packet, Point rangedFrom) {
        /* 3228 */
        broadcastMessage(source, packet, GameConstants.maxViewRangeSq().doubleValue(), rangedFrom);

    }



    public void broadcastMessage(MapleCharacter source, byte[] packet, double rangeSq, Point rangedFrom) {
        /* 3232 */
        this.charactersLock.readLock().lock();

        try {
            /* 3234 */
            this.characters.stream().filter(chr -> (chr != source)).forEach(chr -> {

                if (rangeSq < Double.POSITIVE_INFINITY) {

                    if (rangedFrom.distanceSq(chr.getTruePosition()) <= rangeSq) {

                        chr.send(packet);

                    }

                } else {

                    chr.send(packet);

                }

            });

        } finally {
            /* 3244 */
            this.charactersLock.readLock().unlock();

        }

    }








    private void sendObjectPlacement(MapleCharacter chr) {
        /* 3254 */
        if (chr == null) {

            return;

        }
        /* 3257 */
        getMapObjectsInRange(chr.getTruePosition(), chr.getRange().doubleValue(), GameConstants.rangedMapobjectTypes).forEach(o -> {

            if (o.getType() == MapleMapObjectType.REACTOR && !((MapleReactor) o).isAlive()) {

                return;

            }

            o.sendSpawnData(chr.getClient());

            chr.addVisibleMapObject(o);

        });

    }












    public List<MaplePortal> getPortalsInRange(Point from, double rangeSq) {
        /* 3276 */
        return (List<MaplePortal>) this.portals.values().stream()
/* 3277 */.filter(type -> (from.distanceSq(type.getPosition()) <= rangeSq && type.getTargetMapId() != this.mapid && type.getTargetMapId() != 999999999))
/* 3278 */.collect(Collectors.toList());

    }










    public List<MapleMapObject> getMapObjectsInRange(Point from, double rangeSq) {
        /* 3289 */
        List<MapleMapObject> ret = new ArrayList<>();
        /* 3290 */
        for (MapleMapObjectType type : MapleMapObjectType.values()) {
            /* 3291 */
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(type)).readLock().lock();

        }





        /* 3298 */
        return ret;

    }










    public List<MapleMapObject> getItemsInRange(Point from, double rangeSq) {
        /* 3309 */
        return getMapObjectsInRange(from, rangeSq, Collections.singletonList(MapleMapObjectType.ITEM));

    }










    public List<MapleMapObject> getMonstersInRange(Point from, double rangeSq) {
        /* 3320 */
        return getMapObjectsInRange(from, rangeSq, Collections.singletonList(MapleMapObjectType.MONSTER));

    }











    public List<MapleMapObject> getMapObjectsInRange(Point from, double rangeSq, List<MapleMapObjectType> MapObject_types) {
        List<MapleMapObject> ret = new ArrayList<>();
        for (MapleMapObjectType type : MapleMapObjectType.values()) {
            mapobjectlocks.get(type).readLock().lock();
            try {
                Iterator<MapleMapObject> itr = mapobjects.get(type).values().iterator();
                while (itr.hasNext()) {
                    MapleMapObject mmo = itr.next();
                    if (from.distanceSq(mmo.getPosition()) <= rangeSq) {
                        ret.add(mmo);
                    }
                }
            } finally {
                mapobjectlocks.get(type).readLock().unlock();
            }
        }
        return ret;

    }



    public List<MapleMapObject> getItemsInRect(Rectangle box) {
        /* 3345 */
        return getMapObjectsInRect(box, Collections.singletonList(MapleMapObjectType.ITEM));

    }



    public List<MapleMapObject> getMonstersInRect(Rectangle box) {
        /* 3349 */
        return getMapObjectsInRect(box, Collections.singletonList(MapleMapObjectType.MONSTER));

    }



    public List<MapleMapObject> getMapObjectsInRect(Rectangle box, List<MapleMapObjectType> MapObject_types) {
        List<MapleMapObject> ret = new ArrayList<>();
        for (MapleMapObjectType type : MapObject_types) {
            mapobjectlocks.get(type).readLock().lock();
            try {
                Iterator<MapleMapObject> itr = mapobjects.get(type).values().iterator();
                while (itr.hasNext()) {
                    MapleMapObject mmo = itr.next();
                    if (box.contains(mmo.getPosition())) {
                        ret.add(mmo);
                    }
                }
            } finally {
                mapobjectlocks.get(type).readLock().unlock();
            }
        }
        return ret;
    }



    public List<MapleCharacter> getCharactersIntersect(Rectangle box) {

        List<MapleCharacter> ret;
        /* 3367 */
        this.charactersLock.readLock().lock();

        try {
            /* 3369 */
            ret = (List<MapleCharacter>) this.characters.stream().filter(chr -> chr.getBounds().intersects(box)).collect(Collectors.toList());

        } finally {
            /* 3371 */
            this.charactersLock.readLock().unlock();

        }
        /* 3373 */
        return ret;

    }




    public List<MapleCharacter> getPlayersInRectAndInList(Rectangle box, List<MapleCharacter> chrList) {

        List<MapleCharacter> character;
        /* 3379 */
        this.charactersLock.readLock().lock();

        try {
            /* 3381 */
            character = (List<MapleCharacter>) this.characters.stream().filter(a -> (chrList.contains(a) && box.contains(a.getTruePosition()))).collect(Collectors.toList());

        } finally {
            /* 3383 */
            this.charactersLock.readLock().unlock();

        }
        /* 3385 */
        return character;

    }



    public void addPortal(MaplePortal myPortal) {
        /* 3389 */
        this.portals.put(Integer.valueOf(myPortal.getId()), myPortal);

    }



    public MaplePortal getPortal(String portalname) {
        /* 3393 */
        return this.portals.values().stream().filter(port -> port.getName().equals(portalname)).findFirst().orElse(null);

    }



    public MaplePortal getPortal(int portalid) {
        /* 3397 */
        return this.portals.get(Integer.valueOf(portalid));

    }



    public List<MaplePortal> getPortalSP() {
        /* 3401 */
        return (List<MaplePortal>) this.portals.values().stream().filter(port -> port.getName().equals("sp")).collect(Collectors.toCollection(LinkedList::new));

    }



    public void resetPortals() {
        /* 3405 */
        this.portals.values().forEach(port -> port.setPortalState(true));

    }



    public MapleFootholdTree getFootholds() {
        /* 3409 */
        return this.footholds;

    }



    public void setFootholds(MapleFootholdTree footholds) {
        /* 3413 */
        this.footholds = footholds;

    }



    public int getNumSpawnPoints() {
        /* 3417 */
        return this.monsterSpawn.size();

    }



    public void loadMonsterRate(boolean first) {
        /* 3421 */
        int spawnSize = this.monsterSpawn.size();
        /* 3422 */
        if (spawnSize >= 20 || this.partyBonusRate > 0) {
            /* 3423 */
            this.maxRegularSpawn = Math.round(spawnSize / this.monsterRate);

        } else {
            /* 3425 */
            this.maxRegularSpawn = (int) Math.ceil((spawnSize * this.monsterRate));

        }
        /* 3427 */
        if (this.fixedMob > 0) {
            /* 3428 */
            this.maxRegularSpawn = this.fixedMob;
            /* 3429 */
        } else if (this.maxRegularSpawn <= 2) {
            /* 3430 */
            this.maxRegularSpawn = 2;
            /* 3431 */
        } else if (this.maxRegularSpawn > spawnSize) {
            /* 3432 */
            this.maxRegularSpawn = Math.max(10, spawnSize);

        }

        /* 3435 */
        Collection<Spawns> newSpawn = new LinkedList<>();
        /* 3436 */
        Collection<Spawns> newBossSpawn = new LinkedList<>();

        /* 3438 */
        this.monsterSpawn.stream().filter(s -> (s.getCarnivalTeam() < 2)).forEach(s -> {

            if (s.getMonster().isBoss()) {

                newBossSpawn.add(s);

            } else {

                newSpawn.add(s);

            }

        });
        /* 3445 */
        this.monsterSpawn.clear();
        /* 3446 */
        this.monsterSpawn.addAll(newBossSpawn);
        /* 3447 */
        this.monsterSpawn.addAll(newSpawn);

        /* 3449 */
        if (first && spawnSize > 0) {
            /* 3450 */
            this.lastSpawnTime = System.currentTimeMillis();
            /* 3451 */
            if (GameConstants.isForceRespawn(this.mapid)) {
                /* 3452 */
                this.createMobInterval = 15000;

            }
            /* 3454 */
            respawn(false);

        }

    }



    public SpawnPoint addMonsterSpawn(MapleMonster monster, int mobTime, byte carnivalTeam, String msg) {
        /* 3459 */
        Point newpos = calcPointBelow(monster.getPosition());
        /* 3460 */
        newpos.y--;
        /* 3461 */
        SpawnPoint sp = new SpawnPoint(monster, newpos, mobTime, carnivalTeam, msg);
        /* 3462 */
        if (carnivalTeam > -1) {
            /* 3463 */
            this.monsterSpawn.add(0, sp);

        } else {
            /* 3465 */
            this.monsterSpawn.add(sp);

        }
        /* 3467 */
        return sp;

    }



    public void addAreaMonsterSpawn(MapleMonster monster, Point pos1, Point pos2, Point pos3, int mobTime, String msg, boolean shouldSpawn, boolean sendWorldMsg) {
        /* 3471 */
        pos1 = calcPointBelow(pos1);
        /* 3472 */
        pos2 = calcPointBelow(pos2);
        /* 3473 */
        pos3 = calcPointBelow(pos3);
        /* 3474 */
        if (pos1 != null) {
            /* 3475 */
            pos1.y--;

        }
        /* 3477 */
        if (pos2 != null) {
            /* 3478 */
            pos2.y--;

        }
        /* 3480 */
        if (pos3 != null) {
            /* 3481 */
            pos3.y--;

        }
        /* 3483 */
        if (pos1 == null && pos2 == null && pos3 == null) {
            /* 3484 */
            System.out.println("WARNING: mapid " + this.mapid + ", monster " + monster.getId() + " could not be spawned.");
            return;

        }
        /* 3486 */
        if (pos1 != null) {
            /* 3487 */
            if (pos2 == null) {
                /* 3488 */
                pos2 = new Point(pos1);

            }
            /* 3490 */
            if (pos3 == null) {
                /* 3491 */
                pos3 = new Point(pos1);

            }
            /* 3493 */
        } else if (pos2 != null) {
            /* 3494 */
            if (pos1 == null) {
                /* 3495 */
                pos1 = new Point(pos2);

            }
            /* 3497 */
            if (pos3 == null) {
                /* 3498 */
                pos3 = new Point(pos2);

            }
            /* 3500 */
        } else if (pos3 != null) {
            /* 3501 */
            if (pos1 == null) {
                /* 3502 */
                pos1 = new Point(pos3);

            }
            /* 3504 */
            if (pos2 == null) {
                /* 3505 */
                pos2 = new Point(pos3);

            }

        }
        /* 3508 */
        this.monsterSpawn.add(new SpawnPointAreaBoss(monster, pos1, pos2, pos3, mobTime, msg, shouldSpawn, sendWorldMsg));

    }



    public List<MapleCharacter> getCharacters() {
        /* 3512 */
        return getCharactersThreadsafe();

    }



    public List<MapleCharacter> getCharactersThreadsafe() {
        /* 3516 */
        List<MapleCharacter> chars = new ArrayList<>();
        /* 3517 */
        this.charactersLock.readLock().lock();

        try {
            /* 3519 */
            for (MapleCharacter mc : this.characters) {
                /* 3520 */
                chars.add(mc);

            }

        } finally {
            /* 3523 */
            this.charactersLock.readLock().unlock();

        }
        /* 3525 */
        return chars;

    }



    public MapleCharacter getCharacterByName(String id) {
        /* 3529 */
        this.charactersLock.readLock().lock();

        try {
            /* 3531 */
            for (MapleCharacter mc : this.characters) {
                /* 3532 */
                if (mc.getName().equalsIgnoreCase(id)) {
                    /* 3533 */
                    return mc;

                }

            }

        } finally {
            /* 3537 */
            this.charactersLock.readLock().unlock();

        }
        /* 3539 */
        return null;

    }



    public MapleCharacter getCharacterById_InMap(int id) {
        /* 3543 */
        return getCharacterById(id);

    }



    public MapleCharacter getCharacterById(int id) {
        /* 3547 */
        this.charactersLock.readLock().lock();

        try {
            /* 3549 */
            for (MapleCharacter mc : this.characters) {
                /* 3550 */
                if (mc.getId() == id) {
                    /* 3551 */
                    return mc;

                }

            }

        } finally {
            /* 3555 */
            this.charactersLock.readLock().unlock();

        }
        /* 3557 */
        return null;

    }









    public void updateMapObjectVisibility(MapleCharacter chr, MapleMapObject mo) {
        /* 3567 */
        if (chr == null) {

            return;

        }
        /* 3570 */
        if (!chr.isMapObjectVisible(mo)) {
            /* 3571 */
            if (mo.getType() == MapleMapObjectType.MIST || mo.getType() == MapleMapObjectType.EXTRACTOR || mo.getType() == MapleMapObjectType.SUMMON || mo.getType() == MapleMapObjectType.FAMILIAR || mo instanceof MechDoor || mo.getTruePosition().distanceSq(chr.getTruePosition()) <= mo.getRange().doubleValue()) {
                /* 3572 */
                chr.addVisibleMapObject(mo);
                /* 3573 */
                mo.sendSpawnData(chr.getClient());

            }

            /* 3576 */
        } else if (!(mo instanceof MechDoor) && mo.getType() != MapleMapObjectType.MIST && mo.getType() != MapleMapObjectType.EXTRACTOR && mo.getType() != MapleMapObjectType.SUMMON && mo.getType() != MapleMapObjectType.FAMILIAR && mo.getTruePosition().distanceSq(chr.getTruePosition()) > mo.getRange().doubleValue()) {
            /* 3577 */
            chr.removeVisibleMapObject(mo);
            /* 3578 */
            mo.sendDestroyData(chr.getClient());
            /* 3579 */
        } else if (mo.getType() == MapleMapObjectType.MONSTER &&
                /* 3580 */       chr.getTruePosition().distanceSq(mo.getTruePosition()) <= GameConstants.maxViewRangeSq_Half().doubleValue()) {
            /* 3581 */
            updateMonsterController((MapleMonster) mo);

        }

    }





    public void moveMonster(MapleMonster monster, Point reportedPos) {
        /* 3588 */
        monster.setPosition(reportedPos);

        /* 3590 */
        this.charactersLock.readLock().lock();

        try {
            /* 3592 */
            for (MapleCharacter mc : this.characters) {
                /* 3593 */
                updateMapObjectVisibility(mc, (MapleMapObject) monster);

            }

        } finally {
            /* 3596 */
            this.charactersLock.readLock().unlock();

        }

    }









    public void movePlayer(MapleCharacter player, Point newPosition) {
        /* 3607 */
        player.setPosition(newPosition);
        /* 3608 */
        if (player.getReactor().get() != null) {
            /* 3609 */
            ((MapleReactor) player.getReactor().get()).setPosition(newPosition);

        }

        try {
            /* 3612 */
            Collection<MapleMapObject> visibleObjects = player.getAndWriteLockVisibleMapObjects();
            /* 3613 */
            ArrayList<MapleMapObject> copy = new ArrayList<>(visibleObjects);
            /* 3614 */
            for (MapleMapObject mo : copy) {
                /* 3615 */
                if (mo != null && getMapObject(mo.getObjectId(), mo.getType()) == mo) {
                    /* 3616 */
                    updateMapObjectVisibility(player, mo);
                    continue;
                    /* 3617 */
                }
                if (mo != null) {
                    /* 3618 */
                    visibleObjects.remove(mo);

                }

            }
            /* 3621 */
            for (MapleMapObject mo : getMapObjectsInRange(player.getPosition(), GameConstants.maxViewRangeSq().doubleValue())) {
                /* 3622 */
                if (mo != null && !player.isMapObjectVisible(mo)) {
                    /* 3623 */
                    mo.sendSpawnData(player.getClient());
                    /* 3624 */
                    visibleObjects.add(mo);

                }

            }

        } finally {
            /* 3628 */
            player.unlockWriteVisibleMapObjects();

        }

    }



    public MaplePortal findClosestSpawnpoint(Point from) {
        /* 3633 */
        MaplePortal closest = getPortal(0);
        /* 3634 */
        double shortestDistance = Double.POSITIVE_INFINITY;
        /* 3635 */
        for (MaplePortal portal : this.portals.values()) {
            /* 3636 */
            double distance = portal.getPosition().distanceSq(from);
            /* 3637 */
            if (portal.getType() >= 0 && portal.getType() <= 2 && distance < shortestDistance && portal.getTargetMapId() == 999999999) {
                /* 3638 */
                closest = portal;
                /* 3639 */
                shortestDistance = distance;

            }

        }
        /* 3642 */
        return closest;

    }



    public MaplePortal findClosestPortal(Point from) {
        /* 3646 */
        MaplePortal closest = getPortal(0);
        /* 3647 */
        double shortestDistance = Double.POSITIVE_INFINITY;
        /* 3648 */
        for (MaplePortal portal : this.portals.values()) {
            /* 3649 */
            double distance = portal.getPosition().distanceSq(from);
            /* 3650 */
            if (distance < shortestDistance) {
                /* 3651 */
                closest = portal;
                /* 3652 */
                shortestDistance = distance;

            }

        }
        /* 3655 */
        return closest;

    }



    public MaplePortal getRandomSpawnpoint() {
        /* 3659 */
        List<MaplePortal> spawnPoints_ = new ArrayList<>();
        /* 3660 */
        for (MaplePortal maplePortal : this.portals.values()) {
            /* 3661 */
            if (maplePortal.getType() >= 0 && maplePortal.getType() <= 2) {
                /* 3662 */
                spawnPoints_.add(maplePortal);

            }

        }
        /* 3665 */
        MaplePortal portal = spawnPoints_.get((new Random()).nextInt(spawnPoints_.size()));
        /* 3666 */
        return (portal != null) ? portal : getPortal(0);

    }











    public String spawnDebug() {
        /* 3678 */
        String sb = "Mobs in map : " + getMobsSize() + " spawnedMonstersOnMap: " + this.spawnedMonstersOnMap + " spawnpoints: " + this.monsterSpawn.size() + " maxRegularSpawn: " + this.maxRegularSpawn + " actual monsters: " + getNumMonsters() + " monster rate: " + this.monsterRate + " fixed: " + this.fixedMob;





        /* 3684 */
        return sb;

    }



    public int getMapObjectSize() {
        /* 3688 */
        return this.mapobjects.size();

    }



    public int getCharactersSize() {
        /* 3692 */
        int ret = 0;
        /* 3693 */
        this.charactersLock.readLock().lock();

        try {
            /* 3695 */
            for (MapleCharacter character : this.characters) {
                /* 3696 */
                ret++;

            }

        } finally {
            /* 3699 */
            this.charactersLock.readLock().unlock();

        }
        /* 3701 */
        return ret;

    }



    public Collection<MaplePortal> getPortals() {
        /* 3705 */
        return Collections.unmodifiableCollection(this.portals.values());

    }



    public int getSpawnedMonstersOnMap() {
        /* 3709 */
        return this.spawnedMonstersOnMap.get();

    }



    public int getSpawnedForcesOnMap() {
        /* 3713 */
        return this.spawnedForcesOnMap.incrementAndGet();

    }



    public int getSpawnedMistOnMap() {
        /* 3717 */
        return this.spawnedMistOnMap.incrementAndGet();

    }



    public void respawn(boolean force) {
        /* 3721 */
        respawn(force, System.currentTimeMillis());

    }
















































    public void respawn(boolean force, long now) {
        /* 3770 */
        this.lastSpawnTime = now;


        /* 3773 */
        int extraSpawnNum = 0;

        /* 3775 */
        double rate = 0.0D;

        /* 3777 */
        List<Integer> addedSummon = new ArrayList<>();

        /* 3779 */
        List<MapleSummon> summons = getAllSummonsThreadsafe();
        /* 3780 */
        for (MapleSummon summon : summons) {
            /* 3781 */
            if (addedSummon.contains(Integer.valueOf(summon.getSkillId()))) {

                continue;

            }

            /* 3785 */
            addedSummon.add(Integer.valueOf(summon.getSkillId()));
            /* 3786 */
            switch (summon.getSkillId()) {

                case 80011261:
                    /* 3788 */
                    rate = 2.0D;

                    break;

            }
            /* 3791 */
            extraSpawnNum = (int) (extraSpawnNum + this.monsterSpawn.size() * rate);

        }

        /* 3794 */
        if (force) {

            /* 3796 */
            int numShouldSpawn = this.monsterSpawn.size() + extraSpawnNum - this.spawnedMonstersOnMap.get();
            /* 3797 */
            if (numShouldSpawn > 0) {
                /* 3798 */
                int spawned = 0;

                /* 3800 */
                for (Spawns spawnPoint : this.monsterSpawn) {
                    /* 3801 */
                    spawnPoint.spawnMonster(this);
                    /* 3802 */
                    spawned++;
                    /* 3803 */
                    if (spawned >= numShouldSpawn) {

                        break;

                    }

                }

            }

        } else {

            /* 3810 */
            int defaultNum = (GameConstants.isForceRespawn(this.mapid) ? this.monsterSpawn.size() : this.maxRegularSpawn) + extraSpawnNum - this.spawnedMonstersOnMap.get();

            /* 3812 */
            int numShouldSpawn = (ServerConfig.CHANNEL_MONSTER_MAXCOUNT > 0) ? Math.max(defaultNum, ServerConfig.CHANNEL_MONSTER_MAXCOUNT + extraSpawnNum) : defaultNum;
            /* 3813 */
            if (numShouldSpawn > 0) {
                /* 3814 */
                int spawned = 0;

                /* 3816 */
                List<Spawns> randomSpawn = new ArrayList<>(this.monsterSpawn);
                /* 3817 */
                Collections.shuffle(randomSpawn);

                /* 3819 */
                for (Spawns spawnPoint : randomSpawn) {
                    /* 3820 */
                    if (!this.isSpawns && spawnPoint.getMobTime() > 0) {

                        continue;

                    }
                    /* 3823 */
                    if (spawnPoint.shouldSpawn(this.lastSpawnTime) || GameConstants.isForceRespawn(this.mapid) || (this.monsterSpawn.size() < 10 && this.maxRegularSpawn > this.monsterSpawn.size() && this.partyBonusRate > 0)) {
                        /* 3824 */
                        spawnPoint.spawnMonster(this);
                        /* 3825 */
                        spawned++;

                    }
                    /* 3827 */
                    if (spawned >= numShouldSpawn) {

                        break;

                    }

                }

            }

        }

    }




















    public String getSnowballPortal() {
        /* 3853 */
        int[] teamss = new int[2];
        /* 3854 */
        this.charactersLock.readLock().lock();

        try {
            /* 3856 */
            for (MapleCharacter chr : this.characters) {
                /* 3857 */
                if ((chr.getTruePosition()).y > -80) {
                    /* 3858 */
                    teamss[0] = teamss[0] + 1;
                    continue;

                }
                /* 3860 */
                teamss[1] = teamss[1] + 1;

            }

        } finally {

            /* 3864 */
            this.charactersLock.readLock().unlock();

        }
        /* 3866 */
        if (teamss[0] > teamss[1]) {
            /* 3867 */
            return "st01";

        }
        /* 3869 */
        return "st00";

    }




    public boolean isDisconnected(int id) {
        /* 3874 */
        return this.dced.contains(Integer.valueOf(id));

    }



    public void addDisconnected(int id) {
        /* 3878 */
        this.dced.add(Integer.valueOf(id));

    }



    public void resetDisconnected() {
        /* 3882 */
        this.dced.clear();

    }



    public void startSpeedRun() {
        /* 3886 */
        MapleSquad squads = getSquadByMap();
        /* 3887 */
        if (squads != null) {
            /* 3888 */
            this.charactersLock.readLock().lock();

            try {
                /* 3890 */
                for (MapleCharacter chr : this.characters) {
                    /* 3891 */
                    if (chr.getName().equals(squads.getLeaderName()) && !chr.isIntern()) {
                        /* 3892 */
                        startSpeedRun(chr.getName());

                        return;

                    }

                }

            } finally {
                /* 3897 */
                this.charactersLock.readLock().unlock();

            }

        }

    }



    public void startSpeedRun(String leader) {
        /* 3903 */
        this.speedRunStart = System.currentTimeMillis();
        /* 3904 */
        this.speedRunLeader = leader;

    }



    public void endSpeedRun() {
        /* 3908 */
        this.speedRunStart = 0L;
        /* 3909 */
        this.speedRunLeader = "";

    }



    public void getRankAndAdd(String leader, String time, ExpeditionType type, long timz, Collection<String> squad) {

        try {
            /* 3914 */
            long lastTime = (SpeedRunner.getSpeedRunData(type) == null) ? 0L : ((Long) (SpeedRunner.getSpeedRunData(type)).right).longValue();
            /* 3915 */
            StringBuilder rett = new StringBuilder();
            /* 3916 */
            if (squad != null) {
                /* 3917 */
                for (String chr : squad) {
                    /* 3918 */
                    rett.append(chr);
                    /* 3919 */
                    rett.append(",");

                }

            }
            /* 3922 */
            String z = rett.toString();
            /* 3923 */
            if (squad != null) {
                /* 3924 */
                z = z.substring(0, z.length() - 1);

            }
            /* 3926 */
            try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection();
                    /* 3927 */           PreparedStatement ps = con.prepareStatement("INSERT INTO speedruns(`type`, `leader`, `timestring`, `time`, `members`) VALUES (?,?,?,?,?)")) {
                /* 3928 */
                ps.setString(1, type.name());
                /* 3929 */
                ps.setString(2, leader);
                /* 3930 */
                ps.setString(3, time);
                /* 3931 */
                ps.setLong(4, timz);
                /* 3932 */
                ps.setString(5, z);
                /* 3933 */
                ps.executeUpdate();

            }


            /* 3937 */
            if (lastTime == 0L) {
                /* 3938 */
                SpeedRunner.addSpeedRunData(type, SpeedRunner.addSpeedRunData(new StringBuilder(SpeedRunner.getPreamble(type)), new HashMap<>(), z, leader, 1, time), timz);

            }

            else {

                /* 3942 */
                SpeedRunner.removeSpeedRunData(type);
                /* 3943 */
                SpeedRunner.loadSpeedRunData(type);

            }
            /* 3945 */
        } catch (Exception e) {
            /* 3946 */
            e.printStackTrace();

        }

    }



    public long getSpeedRunStart() {
        /* 3951 */
        return this.speedRunStart;

    }



    public void disconnectAll() {
        /* 3955 */
        for (MapleCharacter chr : getCharactersThreadsafe()) {
            /* 3956 */
            if (!chr.isGM()) {
                /* 3957 */
                chr.getClient().disconnect(true, false);
                /* 3958 */
                chr.getClient().getSession().close();

            }

        }

    }



    public List<MapleNPC> getAllNPCs() {
        /* 3964 */
        return getAllNPCsThreadsafe();

    }



    public List<MapleNPC> getAllNPCsThreadsafe() {
        ArrayList<MapleNPC> ret = new ArrayList();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.NPC)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject mmo = (MapleMapObject) var2.next();
                ret.add((MapleNPC) mmo);
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.NPC)).readLock().unlock();
        }

        return ret;

    }



    public void resetNPCs() {
        /* 3981 */
        removeNpc(-1);

    }









    public void resetPQ(int level) {
        /* 3991 */
        level = Math.max(level / ServerConfig.EVENT_LEVEL_TRAIT, 1);

        /* 3993 */
        resetFully();
        /* 3994 */
        for (MapleMonster mons : getAllMonstersThreadsafe()) {
            /* 3995 */
            mons.changeLevel(level, true);

        }
        /* 3997 */
        resetSpawnLevel(level);

    }



    public void resetSpawnLevel(int level) {
        /* 4001 */
        for (Spawns spawn : this.monsterSpawn) {
            /* 4002 */
            if (spawn instanceof SpawnPoint) {
                /* 4003 */
                ((SpawnPoint) spawn).setLevel(level);

            }

        }

    }



    public void resetFully() {
        /* 4009 */
        resetFully(true);

    }



    public void resetFully(boolean respawn) {
        /* 4013 */
        killAllMonsters(false);
        /* 4014 */
        reloadReactors();
        /* 4015 */
        removeDrops();
        /* 4016 */
        resetNPCs();
        /* 4017 */
        resetSpawns();
        /* 4018 */
        resetDisconnected();
        /* 4019 */
        endSpeedRun();
        /* 4020 */
        cancelSquadSchedule(true);
        /* 4021 */
        resetPortals();
        /* 4022 */
        if (respawn) {
            /* 4023 */
            respawn(true);

        }

    }



    public void cancelSquadSchedule(boolean interrupt) {
        /* 4028 */
        this.squadTimer = false;
        /* 4029 */
        this.checkStates = true;
        /* 4030 */
        if (this.squadSchedule != null) {
            /* 4031 */
            this.squadSchedule.cancel(interrupt);
            /* 4032 */
            this.squadSchedule = null;

        }

    }



    public void obtacleFall(int count, int type1, int type2) {
        /* 4037 */
        broadcastMessage(MaplePacketCreator.createObtacleAtom(count, type1, type2, this));

    }



    public void removeDrop(int itemid) {
        /* 4041 */
        List<MapleMapItem> mapItems = getAllItemsThreadsafe();
        /* 4042 */
        for (MapleMapItem mapItem : mapItems) {
            /* 4043 */
            if (mapItem.getItemId() == itemid) {
                /* 4044 */
                mapItem.expire(this);

            }

        }

    }



    public void removeDrops() {
        /* 4050 */
        List<MapleMapItem> mapItems = getAllItemsThreadsafe();
        /* 4051 */
        for (MapleMapItem mapItem : mapItems) {
            /* 4052 */
            mapItem.expire(this);

        }

    }



    public void removeDropsDelay() {
        /* 4057 */
        List<MapleMapItem> mapItems = getAllItemsThreadsafe();
        /* 4058 */
        int delay = 0, i = 0;
        /* 4059 */
        for (MapleMapItem mapItem : mapItems) {
            /* 4060 */
            i++;
            /* 4061 */
            if (i < 50) {
                /* 4062 */
                mapItem.expire(this);
                continue;

            }
            /* 4064 */
            delay++;
            /* 4065 */
            if (mapItem.hasFFA()) {
                /* 4066 */
                mapItem.registerFFA((delay * 20));
                continue;

            }
            /* 4068 */
            mapItem.registerExpire((delay * 30));

        }

    }





    public void resetAllSpawnPoint(int mobid, int mobTime) {
        /* 4075 */
        Collection<Spawns> AllSpawnPoints = new LinkedList<>(this.monsterSpawn);
        /* 4076 */
        resetFully();
        /* 4077 */
        this.monsterSpawn.clear();
        /* 4078 */
        for (Spawns spawnPoint : AllSpawnPoints) {
            /* 4079 */
            MapleMonster newMons = MapleLifeFactory.getMonster(mobid);
            /* 4080 */
            newMons.setF(spawnPoint.getF());
            /* 4081 */
            newMons.setFh(spawnPoint.getFh());
            /* 4082 */
            newMons.setPosition(spawnPoint.getPosition());
            /* 4083 */
            addMonsterSpawn(newMons, mobTime, (byte) -1, null);

        }
        /* 4085 */
        loadMonsterRate(true);

    }



    public void resetSpawns() {
        /* 4089 */
        boolean changed = false;
        /* 4090 */
        Iterator<Spawns> AllSpawnPoints = this.monsterSpawn.iterator();
        /* 4091 */
        while (AllSpawnPoints.hasNext()) {
            /* 4092 */
            if (((Spawns) AllSpawnPoints.next()).getCarnivalId() > -1) {
                /* 4093 */
                AllSpawnPoints.remove();
                /* 4094 */
                changed = true;

            }

        }
        /* 4097 */
        setSpawns(true);
        /* 4098 */
        if (changed) {
            /* 4099 */
            loadMonsterRate(true);

        }

    }



    public boolean makeCarnivalSpawn(int team, MapleMonster newMons, int num) {
        /* 4104 */
        MapleNodes.MonsterPoint ret = null;
        /* 4105 */
        for (MapleNodes.MonsterPoint mp : this.nodes.getMonsterPoints()) {
            /* 4106 */
            if (mp.team == team || mp.team == -1) {
                /* 4107 */
                Point newpos = calcPointBelow(new Point(mp.x, mp.y));
                /* 4108 */
                newpos.y--;
                /* 4109 */
                boolean found = false;
                /* 4110 */
                for (Spawns s : this.monsterSpawn) {
                    /* 4111 */
                    if (s.getCarnivalId() > -1 && (mp.team == -1 || s.getCarnivalTeam() == mp.team) && (s.getPosition()).x == newpos.x && (s.getPosition()).y == newpos.y) {
                        /* 4112 */
                        found = true;

                        break;

                    }

                }
                /* 4116 */
                if (!found) {
                    /* 4117 */
                    ret = mp;

                    break;

                }

            }

        }
        /* 4122 */
        if (ret != null) {
            /* 4123 */
            newMons.setCy(ret.cy);
            /* 4124 */
            newMons.setF(0);
            /* 4125 */
            newMons.setFh(ret.fh);
            /* 4126 */
            newMons.setRx0(ret.x + 50);
            /* 4127 */
            newMons.setRx1(ret.x - 50);
            /* 4128 */
            newMons.setPosition(new Point(ret.x, ret.y));
            /* 4129 */
            newMons.setHide(false);
            /* 4130 */
            SpawnPoint sp = addMonsterSpawn(newMons, 1, (byte) team, null);
            /* 4131 */
            sp.setCarnival(num);

        }
        /* 4133 */
        return (ret != null);

    }



    public boolean makeCarnivalReactor(int team, int num) {
        /* 4137 */
        MapleReactor old = getReactorByName(team + "" + num);
        /* 4138 */
        if (old != null && old.getState() < 5) {
            /* 4139 */
            return false;

        }
        /* 4141 */
        Point guardz = null;
        /* 4142 */
        List<MapleReactor> react = getAllReactorsThreadsafe();
        /* 4143 */
        for (Pair<Point, Integer> guard : this.nodes.getGuardians()) {
            /* 4144 */
            if (((Integer) guard.right).intValue() == team || ((Integer) guard.right).intValue() == -1) {
                /* 4145 */
                boolean found = false;
                /* 4146 */
                for (MapleReactor r : react) {
                    /* 4147 */
                    if ((r.getTruePosition()).x == ((Point) guard.left).x && (r.getTruePosition()).y == ((Point) guard.left).y && r.getState() < 5) {
                        /* 4148 */
                        found = true;

                        break;

                    }

                }
                /* 4152 */
                if (!found) {
                    /* 4153 */
                    guardz = (Point) guard.left;

                    break;

                }

            }

        }
        /* 4158 */
        if (guardz != null) {
            /* 4159 */
            MapleReactor my = new MapleReactor(MapleReactorFactory.getReactor(9980000 + team), 9980000 + team);
            /* 4160 */
            my.setState((byte) 1);
            /* 4161 */
            my.setName(team + "" + num);

            /* 4163 */
            spawnReactorOnGroundBelow(my, guardz);

        }
        /* 4165 */
        return (guardz != null);

    }



    public void blockAllPortal() {
        /* 4169 */
        for (MaplePortal p : this.portals.values()) {
            /* 4170 */
            p.setPortalState(false);

        }

    }



    public boolean getAndSwitchTeam() {
        /* 4175 */
        return (getCharactersSize() % 2 != 0);

    }



    public void setSquad(MapleSquadType s) {
        /* 4179 */
        this.squad = s;

    }



    public int getChannel() {
        /* 4183 */
        return this.channel;

    }



    public int getConsumeItemCoolTime() {
        /* 4187 */
        return this.consumeItemCoolTime;

    }



    public void setConsumeItemCoolTime(int ciit) {
        /* 4191 */
        this.consumeItemCoolTime = ciit;

    }



    public int getPermanentWeather() {
        /* 4195 */
        return this.permanentWeather;

    }



    public void setPermanentWeather(int pw) {
        /* 4199 */
        this.permanentWeather = pw;

    }



    public void checkStates(String chr) {
        /* 4203 */
        if (!this.checkStates) {

            return;

        }
        /* 4206 */
        MapleSquad sqd = getSquadByMap();
        /* 4207 */
        EventManager em = getEMByMap();
        /* 4208 */
        int size = getCharactersSize();
        /* 4209 */
        if (sqd != null && sqd.getStatus() == 2) {
            /* 4210 */
            sqd.removeMember(chr);
            /* 4211 */
            if (em != null) {
                /* 4212 */
                if (sqd.getLeaderName().equalsIgnoreCase(chr)) {
                    /* 4213 */
                    em.setProperty("leader", "false");

                }
                /* 4215 */
                if (chr.equals("") || size == 0) {
                    /* 4216 */
                    em.setProperty("state", "0");
                    /* 4217 */
                    em.setProperty("leader", "true");
                    /* 4218 */
                    cancelSquadSchedule(!chr.equals(""));
                    /* 4219 */
                    sqd.clear();
                    /* 4220 */
                    sqd.copy();

                }

            }

        }
        /* 4224 */
        if (em != null && em.getProperty("state") != null && (sqd == null || sqd.getStatus() == 2) && size == 0) {
            /* 4225 */
            em.setProperty("state", "0");
            /* 4226 */
            if (em.getProperty("leader") != null) {
                /* 4227 */
                em.setProperty("leader", "true");

            }

        }
        /* 4230 */
        if (this.speedRunStart > 0L && size == 0) {
            /* 4231 */
            endSpeedRun();

        }

    }










    public void setCheckStates(boolean b) {
        /* 4243 */
        this.checkStates = b;

    }



    public List<MapleNodes.MaplePlatform> getPlatforms() {
        /* 4247 */
        return this.nodes.getPlatforms();

    }



    public Collection<MapleNodes.MapleNodeInfo> getNodes() {
        /* 4251 */
        return this.nodes.getNodes();

    }



    public void setNodes(MapleNodes mn) {
        /* 4255 */
        this.nodes = mn;

    }



    public MapleNodes.MapleNodeInfo getNode(int index) {
        /* 4259 */
        return this.nodes.getNode(index);

    }



    public boolean isLastNode(int index) {
        /* 4263 */
        return this.nodes.isLastNode(index);

    }



    public List<Rectangle> getAreas() {
        /* 4267 */
        return this.nodes.getAreas();

    }



    public Rectangle getArea(int index) {
        /* 4271 */
        return this.nodes.getArea(index);

    }



    public void changeEnvironment(String ms, int type) {
        /* 4275 */
        broadcastMessage(MaplePacketCreator.environmentChange(ms, type, 0));

    }



    public int getNumPlayersInArea(int index) {
        /* 4279 */
        return getNumPlayersInRect(getArea(index));

    }



    public int getNumPlayersInRect(Rectangle rect) {
        /* 4283 */
        int ret = 0;
        /* 4284 */
        this.charactersLock.readLock().lock();


        try {
            /* 4287 */
            for (MapleCharacter character : this.characters) {
                /* 4288 */
                if (rect.contains(character.getTruePosition())) {
                    /* 4289 */
                    ret++;

                }

            }

        } finally {
            /* 4293 */
            this.charactersLock.readLock().unlock();

        }
        /* 4295 */
        return ret;

    }



    public int getNumPlayersItemsInArea(int index) {
        /* 4299 */
        return getNumPlayersItemsInRect(getArea(index));

    }



    public int getNumPlayersItemsInRect(Rectangle rect) {
        int ret = this.getNumPlayersInRect(rect);
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().lock();

        try {
            Iterator var3 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.ITEM)).values().iterator();

            while (var3.hasNext()) {
                MapleMapObject mmo = (MapleMapObject) var3.next();
                if (rect.contains(mmo.getTruePosition())) {
                    ++ret;
                }
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ITEM)).readLock().unlock();
        }

        return ret;

    }



    public void broadcastGMMessage(MapleCharacter source, byte[] packet, boolean repeatToSource) {
        /* 4318 */
        broadcastGMMessage(repeatToSource ? null : source, packet);

    }



    private void broadcastGMMessage(MapleCharacter source, byte[] packet) {
        /* 4322 */
        this.charactersLock.readLock().lock();

        try {
            /* 4324 */
            if (source == null) {
                /* 4325 */
                for (MapleCharacter chr : this.characters) {
                    /* 4326 */
                    if (chr.isStaff()) {
                        /* 4327 */
                        chr.send(packet);

                    }

                }

            } else {
                /* 4331 */
                for (MapleCharacter chr : this.characters) {
                    /* 4332 */
                    if (chr != source && chr.getGMLevel() >= source.getGMLevel()) {
                        /* 4333 */
                        chr.send(packet);

                    }

                }

            }

        } finally {
            /* 4338 */
            this.charactersLock.readLock().unlock();

        }

    }



    public List<Pair<Integer, Integer>> getMobsToSpawn() {
        /* 4343 */
        return this.nodes.getMobsToSpawn();

    }



    public List<Integer> getSkillIds() {
        /* 4347 */
        return this.nodes.getSkillIds();

    }







    public boolean canSpawn(long now) {
        /* 4355 */
        double spawnDelay = 1.0D;
        /* 4356 */
        List<Integer> addedSummon = new LinkedList<>();
        /* 4357 */
        List<MapleSummon> summons = getAllSummonsThreadsafe();
        /* 4358 */
        for (MapleSummon summon : summons) {
            /* 4359 */
            if (addedSummon.contains(Integer.valueOf(summon.getSkillId()))) {

                continue;

            }
            /* 4362 */
            addedSummon.add(Integer.valueOf(summon.getSkillId()));
            /* 4363 */
            switch (summon.getSkillId()) {

                case 80011261:
                    /* 4365 */
                    spawnDelay = ServerConfig.WORLD_SKILL_80011261;

            }


        }
        /* 4369 */
        return (this.lastSpawnTime > 0L && this.lastSpawnTime + ((ServerConfig.CHANNEL_MONSTER_REFRESH > 0) ? ((ServerConfig.CHANNEL_MONSTER_REFRESH * 1000) * spawnDelay) : Math.max(2000.0D, this.createMobInterval * spawnDelay)) < now);

    }





    public boolean canHurt(long now) {
        /* 4375 */
        if (this.lastHurtTime > 0L && this.lastHurtTime + this.decHPInterval < now) {
            /* 4376 */
            this.lastHurtTime = now;
            /* 4377 */
            return true;

        }
        /* 4379 */
        return false;

    }



    public void resetShammos(MapleClient c) {
        /* 4383 */
        killAllMonsters(true);
        /* 4384 */
        broadcastMessage(MaplePacketCreator.serverNotice(5, "A player has moved too far from Shammos. Shammos is going back to the start."));
        /* 4385 */
        Timer.EtcTimer.getInstance().schedule(() -> {
            if (c.getPlayer() != null) {
                c.getPlayer().changeMap(this, getPortal(0));
                if (getCharactersThreadsafe().size() > 1) {
                    MapScriptMethods.startScript_FirstUser(c, "shammos_Fenter");
                }
            }
        }, 500L);

    }










    public int getInstanceId() {
        /* 4396 */
        return this.instanceid;

    }



    public void setInstanceId(int ii) {
        /* 4400 */
        this.instanceid = ii;

    }



    public int getPartyBonusRate() {
        /* 4404 */
        return this.partyBonusRate;

    }



    public void setPartyBonusRate(int ii) {
        /* 4408 */
        this.partyBonusRate = ii;

    }



    public short getTop() {
        /* 4412 */
        return this.top;

    }



    public void setTop(int ii) {
        /* 4416 */
        this.top = (short) ii;

    }



    public short getBottom() {
        /* 4420 */
        return this.bottom;

    }



    public void setBottom(int ii) {
        /* 4424 */
        this.bottom = (short) ii;

    }



    public short getLeft() {
        /* 4428 */
        return this.left;

    }



    public void setLeft(int ii) {
        /* 4432 */
        this.left = (short) ii;

    }



    public short getRight() {
        /* 4436 */
        return this.right;

    }



    public void setRight(int ii) {
        /* 4440 */
        this.right = (short) ii;

    }



    public List<Pair<Point, Integer>> getGuardians() {
        /* 4444 */
        return this.nodes.getGuardians();

    }



    public MapleNodes.DirectionInfo getDirectionInfo(int i) {
        /* 4448 */
        return this.nodes.getDirection(i);

    }










    public void AutoNx(int jsNx, boolean isAutoPoints) {
        /* 4459 */
        if (this.mapid != 910000000) {

            return;

        }
        /* 4462 */
        for (MapleCharacter chr : this.characters) {
            /* 4463 */
            if (chr != null) {



                /* 4467 */
                if (isAutoPoints) {
                    /* 4468 */
                    chr.gainPlayerPoints(jsNx);
                    /* 4469 */
                    chr.dropMessage(5, "[系统奖励] 在线时间奖励获得 [" + jsNx + "] 点积分.");
                    continue;

                }
                /* 4471 */
                int givNx = chr.getLevel() / 10 + jsNx;
                /* 4472 */
                chr.modifyCSPoints(2, givNx);
                /* 4473 */
                chr.dropMessage(5, "[系统奖励] 在线时间奖励获得 [" + givNx + "] 点抵用券.");

            }

        }

    }







    public void AutoGain(int jsexp, int expRate) {
        /* 4483 */
        if (this.mapid != 910000000) {

            return;

        }
        /* 4486 */
        for (MapleCharacter chr : this.characters) {
            /* 4487 */
            if (chr == null || chr.getLevel() >= 250) {

                return;

            }
            /* 4490 */
            int givExp = jsexp * chr.getLevel() + expRate;
            /* 4491 */
            givExp *= 3;
            /* 4492 */
            chr.gainExp(givExp, true, false, true);
            /* 4493 */
            chr.dropMessage(5, "[系统奖励] 在线时间奖励获得 [" + givExp + "] 点经验.");

        }

    }






    public boolean isMarketMap() {
        /* 4501 */
        return (this.mapid >= 910000000 && this.mapid <= 910000017);

    }






    public boolean isPvpMaps() {
        /* 4508 */
        return (isPvpMap() || isPartyPvpMap() || isGuildPvpMap());

    }






    public boolean isPvpMap() {
        /* 4515 */
        return ServerConstants.isPvpMap(this.mapid);

    }






    public boolean isPartyPvpMap() {
        /* 4522 */
        return (this.mapid == 910000019 || this.mapid == 910000020);

    }






    public boolean isGuildPvpMap() {
        /* 4529 */
        return (this.mapid == 910000021 || this.mapid == 910000022);

    }






    public boolean isBossMap() {
        /* 4536 */
        switch (this.mapid) {

            case 105100300:

            case 105100400:

            case 211070100:

            case 211070101:

            case 211070110:

            case 220080001:

            case 240040700:

            case 240060200:

            case 240060201:

            case 262031300:

            case 262031310:

            case 270050100:

            case 271040100:

            case 271040200:

            case 272030400:

            case 272030420:

            case 280030000:

            case 280030001:

            case 280030100:

            case 300030310:

            case 551030200:

            case 802000111:

            case 802000211:

            case 802000311:

            case 802000411:

            case 802000611:

            case 802000711:

            case 802000801:

            case 802000802:

            case 802000803:

            case 802000821:

            case 802000823:
                /* 4569 */
                return true;

        }
        /* 4571 */
        return false;

    }







    public void checkMoveMonster(Point from, boolean fly, MapleCharacter chr) {
        /* 4579 */
        if (this.maxRegularSpawn <= 2 || this.monsterSpawn.isEmpty() || this.monsterRate <= 1.0D || chr == null) {

            return;

        }
        /* 4582 */
        int check = (int) ((fly ? 70 : 60) / 100.0D * this.maxRegularSpawn);

        /* 4584 */
        if (getMonstersInRange(from, 5000.0D).size() >= check)
             {
            /* 4586 */
            for (MapleMapObject obj : getMonstersInRange(from, Double.POSITIVE_INFINITY)) {
                /* 4587 */
                MapleMonster mob = (MapleMonster) obj;
                /* 4588 */
                killMonster(mob, chr, false, false, (byte) 1);

            }

        }

    }






    public void spawnArrowsTurret(MapleArrowsTurret aturet) {
        /* 4597 */
        Timer.MapTimer tMan = Timer.MapTimer.getInstance();

        /* 4599 */
        spawnAndAddRangedMapObject(aturet, c -> {

            broadcastMessage(BuffPacket.isArrowsTurretAction(aturet, false));

            c.announce(BuffPacket.isArrowsTurretAction(aturet, true));

        });
        /* 4603 */
        ScheduledFuture poisonSchedule = tMan.register(() -> {
            if (getCharacterById(aturet.getOwnerId()) == null) {
                removeMapObject(aturet);
                broadcastMessage(BuffPacket.cancelArrowsTurret(aturet));
            }
        }, 500L, 500L);






        /* 4610 */
        aturet.setSchedule(tMan.schedule(() -> {
            poisonSchedule.cancel(false);
            removeMapObject(aturet);
            broadcastMessage(BuffPacket.cancelArrowsTurret(aturet));
        }, (20L +



                /* 4614 */           (long) Math.floor((aturet.getSkillLevel() / 3))) * 1000L));

    }






    public List<MapleArrowsTurret> getAllArrowsTurrets() {
        /* 4621 */
        return getArrowsTurretsThreadsafe();

    }



    public List<MapleArrowsTurret> getArrowsTurretsThreadsafe() {
        List<MapleArrowsTurret> ret = new ArrayList();
        ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ARROWS_TURRET)).readLock().lock();

        try {
            Iterator var2 = ((LinkedHashMap) this.mapobjects.get(MapleMapObjectType.ARROWS_TURRET)).values().iterator();

            while (var2.hasNext()) {
                MapleMapObject mmo = (MapleMapObject) var2.next();
                ret.add((MapleArrowsTurret) mmo);
            }
        } finally {
            ((ReentrantReadWriteLock) this.mapobjectlocks.get(MapleMapObjectType.ARROWS_TURRET)).readLock().unlock();
        }

        return ret;

    }



    public void addKSPsychicObject(int chrid, int skillid, List<KSPsychicSkillEntry> infos) {
        /* 4638 */
        Map<Integer, List<Pair<Integer, Integer>>> ksobj = new HashMap<>();
        /* 4639 */
        List<Pair<Integer, Integer>> objs = new ArrayList<>();
        /* 4640 */
        for (KSPsychicSkillEntry ksse : infos) {
            /* 4641 */
            objs.add(new Pair(Integer.valueOf(ksse.getOid()), Integer.valueOf((ksse.getMobOid() != 0) ? ksse.getMobOid() : ksse.getObjectid())));

        }
        /* 4643 */
        ksobj.put(Integer.valueOf(skillid), objs);
        /* 4644 */
        this.kspsychicObjects.put(Integer.valueOf(chrid), ksobj);

    }



    public int removeKSPsychicObject(int chrid, int skillid, int moboid) {
        /* 4648 */
        int oid = -1;
        /* 4649 */
        this.kspsychicLock.writeLock().lock();

        try {
            /* 4651 */
            if (!this.kspsychicObjects.containsKey(Integer.valueOf(chrid)))
                /* 4652 */ return oid;
            /* 4653 */
            if (!((Map) this.kspsychicObjects.get(Integer.valueOf(chrid))).containsKey(Integer.valueOf(skillid))) {
                /* 4654 */
                return oid;

            }
            /* 4656 */
            Iterator<Pair<Integer, Integer>> it = ((List<Pair<Integer, Integer>>) ((Map) this.kspsychicObjects.get(Integer.valueOf(chrid))).get(Integer.valueOf(skillid))).iterator();
            /* 4657 */
            while (it.hasNext()) {
                /* 4658 */
                Pair<Integer, Integer> ks = it.next();
                /* 4659 */
                if (((Integer) ks.getRight()).intValue() == moboid) {
                    /* 4660 */
                    oid = ((Integer) ks.getLeft()).intValue();
                    /* 4661 */
                    it.remove();

                }

            }

        } finally {
            /* 4665 */
            this.kspsychicLock.writeLock().unlock();

        }
        /* 4667 */
        return oid;

    }



    public void addKSUltimateSkill(int chrid, int moboid) {
        /* 4671 */
        this.ksultimates.put(Integer.valueOf(chrid), Integer.valueOf(moboid));

    }



    public void removeKSUltimateSkill(int chrid) {
        /* 4675 */
        this.ksultimates.remove(Integer.valueOf(chrid));

    }



    public boolean isKSUltimateSkill(int chrid, int moboid) {
        /* 4679 */
        return (this.ksultimates.containsKey(Integer.valueOf(chrid)) && ((Integer) this.ksultimates.get(Integer.valueOf(chrid))).intValue() == moboid);

    }

































































    public Point getRandomPos() {

        Point point;
        /* 4746 */
        ArrayList<Point> arrayList = new ArrayList<>();
        /* 4747 */
        getFootholds().getAllRelevants().forEach(p2 -> {

            int n2 = p2.getX1();


            int n3 = p2.getX2();

            int n4 = p2.getY1();

            int n5 = p2.getY2();

            int n6 = 0;

            if (n2 > n4) {

                n6 = n2;

                n2 = n4;

                n4 = n6;

            }

            if (n3 > n5) {

                n6 = n3;

                n3 = n5;

                n5 = n6;

            }

            arrayList.add(new Point(Randomizer.rand(n2, n4), Randomizer.rand(n3, n5)));

        });
        /* 4766 */
        int i = 0;

        do {
            /* 4768 */
            point = arrayList.get(Randomizer.nextInt(arrayList.size()));
            /* 4769 */
            i++;
            /* 4770 */
        } while (getFootholds().findBelow(point, false) == null && i < 200);





        /* 4776 */
        return point;

    }



    public void setEntrustedFishing(boolean entrustedFishing) {
        /* 4780 */
        this.entrustedFishing = entrustedFishing;

    }




    public boolean allowFishing() {
        /* 4785 */
        return this.entrustedFishing;

    }











    public void onDragon(int phase, int posX, int posY, int createPosX, int createPosY, boolean isLeft) {
        /* 4797 */
        broadcastMessage(LucidPacket.createDragon(phase, posX, posY, createPosX, createPosY, isLeft));

    }






    public void ShowSteps(boolean enable) {
        /* 4804 */
        List<String> name = new ArrayList<>();
        /* 4805 */
        name.add("Bblue3");
        /* 4806 */
        name.add("Bblue2");
        /* 4807 */
        name.add("Bblue1");
        /* 4808 */
        name.add("except2");
        /* 4809 */
        name.add("except1");
        /* 4810 */
        name.add("except4");
        /* 4811 */
        name.add("except3");
        /* 4812 */
        name.add("Bred3");
        /* 4813 */
        name.add("Bred2");
        /* 4814 */
        name.add("Bred1");
        /* 4815 */
        name.add("Myellow3");
        /* 4816 */
        name.add("Myellow1");
        /* 4817 */
        name.add("Myellow2");
        /* 4818 */
        name.add("Mred2");
        /* 4819 */
        name.add("Mred3");
        /* 4820 */
        broadcastMessage(LucidPacket.ShowSteps(enable, name));

    }






    public void createSwordNode(int n2) {
        /* 4827 */
        createSwordNode(n2, null);

    }






    public void createSwordNode(int n2, Point point) {

        int oid;
        /* 4835 */
        if (this.swordNodes == null) {
            /* 4836 */
            this.swordNodes = new HashMap<>();

        }
        /* 4838 */
        this.runningOidLock.lock();

        try {
            /* 4840 */
            oid = this.runningOid.getAndIncrement();

        } finally {
            /* 4842 */
            this.runningOidLock.unlock();

        }
        /* 4844 */
        Point point2 = (point == null) ? new Point(Randomizer.rand(this.left, this.right), -200) : point;
        /* 4845 */
        MapleSwordNode swordNode = new MapleSwordNode(n2, oid, point2);
        /* 4846 */
        this.swordNodes.put(Integer.valueOf(oid), swordNode);
        /* 4847 */
        broadcastMessage(MobPacket.CreateDemianFlyingSword(true, oid, n2, point2));
        /* 4848 */
        broadcastMessage(MobPacket.NodeDemianFlyingSword(oid, false, swordNode));
        /* 4849 */
        int chrid = ((MapleCharacter) getCharacters().get(Randomizer.nextInt(getCharactersSize()))).getId();
        /* 4850 */
        swordNode.setBKM(chrid);
        /* 4851 */
        broadcastMessage(MobPacket.TargetDemianFlyingSword(oid, chrid));
        /* 4852 */
        swordNodeAck(oid, false);

    }



    public void swordNodeAck(int oid, boolean bl2) {
        /* 4856 */
        swordNodeAck(oid, bl2, 0, 0, 0, 0);

    }



    public void swordNodeAck(int oid, boolean bl2, int S_x, int S_y, int C_x, int C_y) {
        /* 4860 */
        MapleSwordNode fiyingSword = this.swordNodes.get(Integer.valueOf(oid));
        /* 4861 */
        if (fiyingSword == null) {

            return;

        }
        /* 4864 */
        if (fiyingSword.getSwordNodeInfos().size() < 14) {

            /* 4866 */
            fiyingSword.SpawnFiyingSword(this.top, this.bottom, this.left, this.right, bl2);
            /* 4867 */
            broadcastMessage(MobPacket.NodeDemianFlyingSword(oid, true, this.swordNodes.get(Integer.valueOf(oid))));

        } else {

            /* 4870 */
            fiyingSword.gainCount();

            MobSkill mobSkill;
            /* 4872 */
            if (fiyingSword.getCount() >= 14 && (mobSkill = MobSkillFactory.getMobSkill(131, 28)) != null) {

                /* 4874 */
                Point point = new Point(S_x, S_y);
                /* 4875 */
                MapleMonster monster = getMonsterById(fiyingSword.getMonsterId());
                /* 4876 */
                if (monster != null) {
                    /* 4877 */
                    MapleMist l2 = new MapleMist(mobSkill.calculateBoundingBox(point, true), monster, mobSkill, point);
                    /* 4878 */
                    l2.setSkillDelay(0);
                    /* 4879 */
                    l2.setMistType(1);
                    /* 4880 */
                    spawnMist(l2, 15000, false);

                }

            }

        }

    }



    public void swordNodeEnd(int oid) {
        /* 4887 */
        MapleSwordNode swordNode = this.swordNodes.get(Integer.valueOf(oid));
        /* 4888 */
        if (swordNode == null) {

            return;

        }

        /* 4892 */
        MapleMonster monster = getMonsterById(swordNode.getMonsterId());
        /* 4893 */
        if (monster == null) {

            return;

        }
        /* 4896 */
        if (swordNode.getSwordNodeInfos().size() >= 14) {
            /* 4897 */
            swordNode.getSwordNodeInfos().clear();
            /* 4898 */
            Point point = swordNode.getPoint();
            /* 4899 */
            createSwordNode(swordNode.getMonsterId(), point);

        }

    }



    public void spawnFallingDrop(int itemid) {

        Item idrop = new Item();
        /* 4905 */
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        /* 4906 */
        if (ItemConstants.getInventoryType(itemid) == MapleInventoryType.EQUIP) {
            /* 4907 */
            Equip equip = ii.randomizeStats((Equip) ii.getEquipById(itemid));

        } else {
            /* 4909 */
            idrop = new Item(itemid, (short) 0, (short) 1, (short) 0);

        }
        /* 4911 */
        if (idrop != null) {
            /* 4912 */
            spawnFallingDrop(idrop, getRandPoint());

        }

    }



    public void spawnFallingDrop(Item item, Point point) {
        /* 4917 */
        MapleMapItem dropItem = new MapleMapItem(item, point, 0, (byte) 2, false, 0);
        /* 4918 */
        dropItem.setFallingVY((short) Randomizer.rand(100, 255));
        /* 4919 */
        dropItem.setDelay(100);
        /* 4920 */
        dropItem.setDropFrom(new Point(point.x, getTop()));
        /* 4921 */
        dropItem.setEnterType((byte) 1);
        /* 4922 */
        spawnAndAddRangedMapObject(dropItem, c -> c.announce(InventoryPacket.dropItemFromMapObject(dropItem, dropItem.getDropFrom(), point, dropItem.getEnterType(), false)));
        /* 4923 */
        dropItem.setEnterType((byte) 0);
        /* 4924 */
        broadcastMessage(InventoryPacket.dropItemFromMapObject(dropItem, dropItem.getDropFrom(), point, dropItem.getEnterType(), false), point);
        /* 4925 */
        dropItem.registerExpire(120000L);

    }



    public final Point getRandPoint() {
        /* 4929 */
        ArrayList<Object> list = new ArrayList();
        /* 4930 */
        getFootholds().getAllRelevants().forEach(n -> list.add(new Point(Randomizer.rand(Math.min(n.getX1(), n.getX2()), Math.max(n.getX1(), n.getX2())), n.getY2())));
        /* 4931 */
        return (Point) list.get(Randomizer.nextInt(list.size()));

    }



    public int getReactorStat(String s) {
        /* 4935 */
        for (MapleReactor reactor : getAllReactorsThreadsafe()) {
            /* 4936 */
            if (reactor.getName().equals(s)) {
                /* 4937 */
                return reactor.getState();

            }

        }
        /* 4940 */
        return -999;

    }



    public void forceTrigger(String s, byte b) {
        /* 4944 */
        getAllReactor().stream().filter(it -> it.getName().equalsIgnoreCase(s)).forEach(it -> it.forceHitReactor(b));

    }



    public void forceTriggerStateEnd(String s, byte newState, byte stateEnd) {
        /* 4948 */
        getAllReactor().stream().filter(it -> it.getName().equalsIgnoreCase(s)).forEach(it -> {

            it.setStateEnd(stateEnd);

            it.forceHitReactor(newState);

        });

    }



    public void forceTrigger(int reactorID, byte newState) {
        /* 4955 */
        getAllReactor().stream().filter(it -> (it.getReactorId() == reactorID)).forEach(it -> it.forceHitReactor(newState));

    }



    public int getSpawnedSwordOnMap() {
        /* 4959 */
        return this.spawnedSwordOnMap.getAndIncrement();

    }


       private class ActivateItemReactor
             implements Runnable
             {
             private final MapleMapItem mapitem;
             private final MapleReactor reactor;
             private final MapleClient c;



        public ActivateItemReactor(MapleMapItem mapitem, MapleReactor reactor, MapleClient c) {
            /* 4970 */
            this.mapitem = mapitem;
            /* 4971 */
            this.reactor = reactor;
            /* 4972 */
            this.c = c;

        }




        public void run() {
            /* 4977 */
            if (this.mapitem != null && this.mapitem == MapleMap.this.getMapObject(this.mapitem.getObjectId(), this.mapitem.getType()) && !this.mapitem.isPickedUp()) {
                /* 4978 */
                this.mapitem.expire(MapleMap.this);
                /* 4979 */
                this.reactor.hitReactor(this.c);
                /* 4980 */
                this.reactor.setTimerActive(false);

                /* 4982 */
                if (this.reactor.getDelay() > 0) {
                    /* 4983 */
                    Timer.MapTimer.getInstance().schedule(() -> this.reactor.forceHitReactor((byte) 0), this.reactor.getDelay());

                }

            } else {
                /* 4986 */
                this.reactor.setTimerActive(false);

            }

        }

    }


       private static interface DelayedPacketCreation {
             void sendPackets(MapleClient param1MapleClient);

    }

}


/* Location:              C:\PGX\Server.jar!\server\maps\MapleMap.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */